Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authormakowalski <makowalski@nvidia.com>2021-07-21 20:18:49 +0300
committermakowalski <makowalski@nvidia.com>2021-07-21 20:18:49 +0300
commit14caaa8c9f5ab66103641ab943193f5fe9d7a54c (patch)
tree8ad6a74d93e8ffbd54babe7b63b2fdf5f9dd8fa8 /source
parent50443ada6504d34f0355487fa19283e171d4293e (diff)
USD import: Clang-Tidy warning fixes.
Diffstat (limited to 'source')
-rw-r--r--source/blender/io/usd/intern/usd_capi_import.cc34
-rw-r--r--source/blender/io/usd/intern/usd_reader_curve.cc5
-rw-r--r--source/blender/io/usd/intern/usd_reader_material.cc14
-rw-r--r--source/blender/io/usd/intern/usd_reader_mesh.cc15
-rw-r--r--source/blender/io/usd/intern/usd_reader_nurbs.cc4
-rw-r--r--source/blender/io/usd/intern/usd_reader_prim.cc4
-rw-r--r--source/blender/io/usd/intern/usd_reader_xform.cc4
-rw-r--r--source/blender/io/usd/usd.h2
8 files changed, 41 insertions, 41 deletions
diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc
index 8507c10d9ae..bbb0922bd69 100644
--- a/source/blender/io/usd/intern/usd_capi_import.cc
+++ b/source/blender/io/usd/intern/usd_capi_import.cc
@@ -172,7 +172,7 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo
DEG_id_tag_update(&import_collection->id, ID_RECALC_COPY_ON_WRITE);
DEG_relations_tag_update(data->bmain);
- WM_main_add_notifier(NC_SCENE | ND_LAYER, NULL);
+ WM_main_add_notifier(NC_SCENE | ND_LAYER, nullptr);
data->view_layer->active_collection = BKE_layer_collection_first_from_scene_collection(
data->view_layer, import_collection);
@@ -248,8 +248,8 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo
USDPrimReader *parent = reader->parent();
- if (parent == NULL) {
- ob->parent = NULL;
+ if (parent == nullptr) {
+ ob->parent = nullptr;
}
else {
ob->parent = parent->object();
@@ -381,7 +381,7 @@ bool USD_import(struct bContext *C,
job->settings.sequence_len = params->sequence_len;
job->error_code = USD_NO_ERROR;
job->was_canceled = false;
- job->archive = NULL;
+ job->archive = nullptr;
job->params = *params;
@@ -399,7 +399,7 @@ bool USD_import(struct bContext *C,
/* setup job */
WM_jobs_customdata_set(wm_job, job, import_freejob);
WM_jobs_timer(wm_job, 0.1, NC_SCENE, NC_SCENE);
- WM_jobs_callbacks(wm_job, import_startjob, NULL, NULL, import_endjob);
+ WM_jobs_callbacks(wm_job, import_startjob, nullptr, nullptr, import_endjob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
@@ -429,23 +429,23 @@ static USDPrimReader *get_usd_reader(CacheReader *reader, Object * /* ob */, con
if (!iobject.IsValid()) {
*err_str = "Invalid object: verify object path";
- return NULL;
+ return nullptr;
}
return usd_reader;
}
-Mesh *USD_read_mesh(CacheReader *reader,
- Object *ob,
- Mesh *existing_mesh,
- const float time,
- const char **err_str,
- const int read_flag)
+struct Mesh *USD_read_mesh(struct CacheReader *reader,
+ struct Object *ob,
+ struct Mesh *existing_mesh,
+ const float time,
+ const char **err_str,
+ const int read_flag)
{
USDGeomReader *usd_reader = dynamic_cast<USDGeomReader *>(get_usd_reader(reader, ob, err_str));
- if (usd_reader == NULL) {
- return NULL;
+ if (usd_reader == nullptr) {
+ return nullptr;
}
return usd_reader->read_mesh(existing_mesh, time, read_flag, err_str);
@@ -456,7 +456,7 @@ bool USD_mesh_topology_changed(
{
USDGeomReader *usd_reader = dynamic_cast<USDGeomReader *>(get_usd_reader(reader, ob, err_str));
- if (usd_reader == NULL) {
+ if (usd_reader == nullptr) {
return false;
}
@@ -493,9 +493,9 @@ CacheReader *CacheReader_open_usd_object(CacheArchiveHandle *handle,
/* TODO(makowalski): The handle does not have the proper import params or settings. */
USDPrimReader *usd_reader = archive->create_reader(prim);
- if (usd_reader == NULL) {
+ if (usd_reader == nullptr) {
/* This object is not supported */
- return NULL;
+ return nullptr;
}
usd_reader->object(object);
usd_reader->incref();
diff --git a/source/blender/io/usd/intern/usd_reader_curve.cc b/source/blender/io/usd/intern/usd_reader_curve.cc
index 675e2a4c17d..c84b768bd36 100644
--- a/source/blender/io/usd/intern/usd_reader_curve.cc
+++ b/source/blender/io/usd/intern/usd_reader_curve.cc
@@ -100,7 +100,7 @@ void USDCurvesReader::read_curve_sample(Curve *cu, const double motionSampleTime
/* If normals, extrude, else bevel.
* Perhaps to be replaced by Blender/USD Schema. */
- if (usdNormals.size() > 0) {
+ if (!usdNormals.empty()) {
// Set extrusion to 1.0f.
curve_->ext1 = 1.0f;
}
@@ -161,8 +161,9 @@ void USDCurvesReader::read_curve_sample(Curve *cu, const double motionSampleTime
bp->weight = weight;
float radius = curve_->width;
- if (idx < usdWidths.size())
+ if (idx < usdWidths.size()) {
radius = usdWidths[idx];
+ }
bp->radius = radius;
}
diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc
index 0a2f487f9c9..a99e65f5792 100644
--- a/source/blender/io/usd/intern/usd_reader_material.cc
+++ b/source/blender/io/usd/intern/usd_reader_material.cc
@@ -260,7 +260,7 @@ Material *USDMaterialReader::add_material(const pxr::UsdShadeMaterial &usd_mater
return nullptr;
}
- std::string mtl_name = usd_material.GetPrim().GetName().GetString().c_str();
+ std::string mtl_name = usd_material.GetPrim().GetName().GetString();
/* Create the material. */
Material *mtl = BKE_material_add(bmain_, mtl_name.c_str());
@@ -293,12 +293,12 @@ void USDMaterialReader::import_usd_preview(Material *mtl,
* and output shaders. */
/* Add the node tree. */
- bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", "ShaderNodeTree");
+ bNodeTree *ntree = ntreeAddTree(nullptr, "Shader Nodetree", "ShaderNodeTree");
mtl->nodetree = ntree;
mtl->use_nodes = true;
/* Create the Principled BSDF shader node. */
- bNode *principled = add_node(NULL, ntree, SH_NODE_BSDF_PRINCIPLED, 0.0f, 300.0f);
+ bNode *principled = add_node(nullptr, ntree, SH_NODE_BSDF_PRINCIPLED, 0.0f, 300.0f);
if (!principled) {
std::cerr << "ERROR: Couldn't create SH_NODE_BSDF_PRINCIPLED node for USD shader "
@@ -307,7 +307,7 @@ void USDMaterialReader::import_usd_preview(Material *mtl,
}
/* Create the material output node. */
- bNode *output = add_node(NULL, ntree, SH_NODE_OUTPUT_MATERIAL, 300.0f, 300.0f);
+ bNode *output = add_node(nullptr, ntree, SH_NODE_OUTPUT_MATERIAL, 300.0f, 300.0f);
if (!output) {
std::cerr << "ERROR: Couldn't create SH_NODE_OUTPUT_MATERIAL node for USD shader "
@@ -513,7 +513,7 @@ void USDMaterialReader::follow_connection(const pxr::UsdShadeInput &usd_input,
float locy = 0.0f;
compute_node_loc(column + 1, locx, locy, r_ctx);
- bNode *normal_map = add_node(NULL, ntree, SH_NODE_NORMAL_MAP, locx, locy);
+ bNode *normal_map = add_node(nullptr, ntree, SH_NODE_NORMAL_MAP, locx, locy);
// Currently, the Normal Map node has Tangent Space as the default,
// which is what we need, so we don't need to explicitly set it.
@@ -553,7 +553,7 @@ void USDMaterialReader::convert_usd_uv_texture(const pxr::UsdShadeShader &usd_sh
compute_node_loc(column, locx, locy, r_ctx);
// Create the Texture Image node.
- bNode *tex_image = add_node(NULL, ntree, SH_NODE_TEX_IMAGE, locx, locy);
+ bNode *tex_image = add_node(nullptr, ntree, SH_NODE_TEX_IMAGE, locx, locy);
if (!tex_image) {
std::cerr << "ERROR: Couldn't create SH_NODE_TEX_IMAGE for node input " << dest_socket_name
@@ -658,7 +658,7 @@ void USDMaterialReader::convert_usd_primvar_reader_float2(
compute_node_loc(column, locx, locy, r_ctx);
// Create the UV Map node.
- bNode *uv_map = add_node(NULL, ntree, SH_NODE_UVMAP, locx, locy);
+ bNode *uv_map = add_node(nullptr, ntree, SH_NODE_UVMAP, locx, locy);
if (!uv_map) {
std::cerr << "ERROR: Couldn't create SH_NODE_UVMAP for node input " << dest_socket_name
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 1238e13941f..f5f47396809 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -63,7 +63,7 @@ static void build_mat_map(const Main *bmain, std::map<std::string, Material *> &
for (; material; material = static_cast<Material *>(material->id.next)) {
// We have to do this because the stored material name is coming directly from usd
- mat_map[pxr::TfMakeValidIdentifier(material->id.name + 2).c_str()] = material;
+ mat_map[pxr::TfMakeValidIdentifier(material->id.name + 2)] = material;
}
}
@@ -155,19 +155,19 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, const int data_type
/* unsupported custom data type -- don't do anything. */
if (!ELEM(cd_data_type, CD_MLOOPUV, CD_MLOOPCOL)) {
- return NULL;
+ return nullptr;
}
loopdata = &mesh->ldata;
cd_ptr = CustomData_get_layer_named(loopdata, cd_data_type, name);
- if (cd_ptr != NULL) {
+ if (cd_ptr != nullptr) {
/* layer already exists, so just return it. */
return cd_ptr;
}
/* Create a new layer. */
numloops = mesh->totloop;
- cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, NULL, numloops, name);
+ cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, nullptr, numloops, name);
return cd_ptr;
}
@@ -199,7 +199,7 @@ void USDMeshReader::read_object_data(Main *bmain, const double motionSampleTime)
Mesh *mesh = (Mesh *)object_->data;
is_initial_load_ = true;
- Mesh *read_mesh = this->read_mesh(mesh, motionSampleTime, import_params_.global_read_flag, NULL);
+ Mesh *read_mesh = this->read_mesh(mesh, motionSampleTime, import_params_.global_read_flag, nullptr);
is_initial_load_ = false;
if (read_mesh != mesh) {
@@ -337,8 +337,9 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo
uv_token = pxr::TfToken(layer_name);
uv_token_map_.insert(std::make_pair(layer_name, uv_token));
}
- else
+ else {
uv_token = uv_token_map_.at(layer_name);
+ }
// Early out if no token found, this should never happen
if (uv_token.IsEmpty()) {
@@ -686,7 +687,7 @@ void USDMeshReader::assign_facesets_to_mpoly(double motionSampleTime,
mesh_prim_);
int current_mat = 0;
- if (subsets.size() > 0) {
+ if (!subsets.empty()) {
for (const pxr::UsdGeomSubset &subset : subsets) {
pxr::UsdShadeMaterialBindingAPI subset_api = pxr::UsdShadeMaterialBindingAPI(
subset.GetPrim());
diff --git a/source/blender/io/usd/intern/usd_reader_nurbs.cc b/source/blender/io/usd/intern/usd_reader_nurbs.cc
index 9055bb97614..510c9e7c8ea 100644
--- a/source/blender/io/usd/intern/usd_reader_nurbs.cc
+++ b/source/blender/io/usd/intern/usd_reader_nurbs.cc
@@ -36,7 +36,7 @@
static bool set_knots(const pxr::VtDoubleArray &knots, float *&nu_knots)
{
- if (knots.size() == 0) {
+ if (knots.empty()) {
return false;
}
@@ -105,7 +105,7 @@ void USDNurbsReader::read_curve_sample(Curve *cu, const double motionSampleTime)
/* If normals, extrude, else bevel.
* Perhaps to be replaced by Blender USD Schema. */
- if (usdNormals.size() > 0) {
+ if (!usdNormals.empty()) {
/* Set extrusion to 1. */
curve_->ext1 = 1.0f;
}
diff --git a/source/blender/io/usd/intern/usd_reader_prim.cc b/source/blender/io/usd/intern/usd_reader_prim.cc
index f0e0faf455c..042f3e5dd62 100644
--- a/source/blender/io/usd/intern/usd_reader_prim.cc
+++ b/source/blender/io/usd/intern/usd_reader_prim.cc
@@ -34,9 +34,7 @@ USDPrimReader::USDPrimReader(const pxr::UsdPrim &prim,
{
}
-USDPrimReader::~USDPrimReader()
-{
-}
+USDPrimReader::~USDPrimReader() = default;
const pxr::UsdPrim &USDPrimReader::prim() const
{
diff --git a/source/blender/io/usd/intern/usd_reader_xform.cc b/source/blender/io/usd/intern/usd_reader_xform.cc
index 12b66518e1e..9fb97f55bfe 100644
--- a/source/blender/io/usd/intern/usd_reader_xform.cc
+++ b/source/blender/io/usd/intern/usd_reader_xform.cc
@@ -43,7 +43,7 @@ void USDXformReader::create_object(Main *bmain, const double /* motionSampleTime
{
object_ = BKE_object_add_only_object(bmain, OB_EMPTY, name_.c_str());
object_->empty_drawsize = 0.1f;
- object_->data = NULL;
+ object_->data = nullptr;
}
void USDXformReader::read_object_data(Main * /* bmain */, const double motionSampleTime)
@@ -55,7 +55,7 @@ void USDXformReader::read_object_data(Main * /* bmain */, const double motionSam
if (!is_constant) {
bConstraint *con = BKE_constraint_add_for_object(
- object_, NULL, CONSTRAINT_TYPE_TRANSFORM_CACHE);
+ object_, nullptr, CONSTRAINT_TYPE_TRANSFORM_CACHE);
bTransformCacheConstraint *data = static_cast<bTransformCacheConstraint *>(con->data);
std::string prim_path = use_parent_xform_ ? prim_.GetParent().GetPath().GetAsString() :
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index 67b34ad58b0..133123af916 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -105,7 +105,7 @@ void USD_get_transform(struct CacheReader *reader, float r_mat[4][4], float time
/* Either modifies current_mesh in-place or constructs a new mesh. */
struct Mesh *USD_read_mesh(struct CacheReader *reader,
struct Object *ob,
- struct Mesh *current_mesh,
+ struct Mesh *existing_mesh,
const float time,
const char **err_str,
int flags);