diff options
author | makowalski <makowalski@nvidia.com> | 2021-07-23 22:20:06 +0300 |
---|---|---|
committer | makowalski <makowalski@nvidia.com> | 2021-07-23 22:20:06 +0300 |
commit | 537a9a7b633f41eece7a0f8a7f32f462585e7d8a (patch) | |
tree | 3226ce3416279c49684388758dca00f5739d2bbe /source | |
parent | e02d956dd27b06ee09b208e9565e8f5a24b094fd (diff) |
USD Import: fix comments.
Now using C-style comments throughout. Also,
putting unused code in #if 0 blocks. Removed
unneeded comments and other miscellaneous fixes.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/io/usd/intern/usd_capi_import.cc | 10 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_camera.cc | 10 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_curve.cc | 2 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_light.cc | 42 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_material.cc | 60 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_material.h | 8 | ||||
-rw-r--r-- | source/blender/io/usd/intern/usd_reader_mesh.cc | 50 | ||||
-rw-r--r-- | source/blender/io/usd/usd.h | 2 |
8 files changed, 96 insertions, 88 deletions
diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index bbb0922bd69..7e6259459d3 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -101,18 +101,17 @@ static bool gather_objects_paths(const pxr::UsdPrim &object, ListBase *object_pa return true; } -// Update the given import settings with the global rotation matrix to orient -// imported objects with Z-up, if necessary +/* Update the given import settings with the global rotation matrix to orient + * imported objects with Z-up, if necessary */ static void convert_to_z_up(pxr::UsdStageRefPtr stage, ImportSettings &r_settings) { if (!stage || pxr::UsdGeomGetStageUpAxis(stage) == pxr::UsdGeomTokens->z) { - // Nothing to do. return; } r_settings.do_convert_mat = true; - // Rotate 90 degrees about the X-axis. + /* Rotate 90 degrees about the X-axis. */ float rmat[3][3]; float axis[3] = {1.0f, 0.0f, 0.0f}; axis_angle_normalized_to_mat3(rmat, axis, M_PI / 2.0f); @@ -157,7 +156,6 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo data->was_canceled = false; data->archive = nullptr; - // G.is_rendering = true; WM_set_locked_interface(data->wm, true); G.is_break = false; @@ -215,7 +213,7 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo convert_to_z_up(stage, data->settings); - // Set up the stage for animated data. + /* Set up the stage for animated data. */ if (data->params.set_frame_range) { data->scene->r.sfra = stage->GetStartTimeCode(); data->scene->r.efra = stage->GetEndTimeCode(); diff --git a/source/blender/io/usd/intern/usd_reader_camera.cc b/source/blender/io/usd/intern/usd_reader_camera.cc index 8606d64c95e..185828a4f40 100644 --- a/source/blender/io/usd/intern/usd_reader_camera.cc +++ b/source/blender/io/usd/intern/usd_reader_camera.cc @@ -67,16 +67,18 @@ void USDCameraReader::read_object_data(Main *bmain, const double motionSampleTim cam_prim.GetHorizontalApertureAttr().Get(&horAp, motionSampleTime); bcam->lens = val.Get<float>(); - // TODO(makowalski) - // bcam->sensor_x = 0.0f; - // bcam->sensor_y = 0.0f; + /* TODO(makowalski) */ +#if 0 + bcam->sensor_x = 0.0f; + bcam->sensor_y = 0.0f; +#endif bcam->shiftx = verApOffset.Get<float>(); bcam->shifty = horApOffset.Get<float>(); bcam->type = (projectionVal.Get<pxr::TfToken>().GetString() == "perspective") ? CAM_PERSP : CAM_ORTHO; - // Calling UncheckedGet() to silence compiler warnings. + /* Calling UncheckedGet() to silence compiler warnings. */ bcam->clip_start = max_ff(0.1f, clippingRangeVal.UncheckedGet<pxr::GfVec2f>()[0]); bcam->clip_end = clippingRangeVal.UncheckedGet<pxr::GfVec2f>()[1]; diff --git a/source/blender/io/usd/intern/usd_reader_curve.cc b/source/blender/io/usd/intern/usd_reader_curve.cc index c84b768bd36..2fd6efc4bb1 100644 --- a/source/blender/io/usd/intern/usd_reader_curve.cc +++ b/source/blender/io/usd/intern/usd_reader_curve.cc @@ -101,7 +101,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.empty()) { - // Set extrusion to 1.0f. + /* Set extrusion to 1.0f. */ curve_->ext1 = 1.0f; } else { diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc index f609682191f..1812a1c229c 100644 --- a/source/blender/io/usd/intern/usd_reader_light.cc +++ b/source/blender/io/usd/intern/usd_reader_light.cc @@ -54,12 +54,12 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime pxr::UsdLuxShapingAPI shapingAPI(light_prim); - // Set light type + /* Set light type. */ if (prim_.IsA<pxr::UsdLuxDiskLight>()) { blight->type = LA_AREA; blight->area_shape = LA_AREA_DISK; - // Ellipse lights are not currently supported + /* Ellipse lights are not currently supported */ } else if (prim_.IsA<pxr::UsdLuxRectLight>()) { blight->type = LA_AREA; @@ -76,20 +76,24 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime blight->type = LA_SUN; } - // Set light values + /* Set light values. */ pxr::VtValue intensity; light_prim.GetIntensityAttr().Get(&intensity, motionSampleTime); blight->energy = intensity.Get<float>() * this->import_params_.light_intensity_scale; - // TODO: Not currently supported - // pxr::VtValue exposure; - // light_prim.GetExposureAttr().Get(&exposure, motionSampleTime); + /* TODO(makowalsk): Not currently supported. */ +#if 0 + pxr::VtValue exposure; + light_prim.GetExposureAttr().Get(&exposure, motionSampleTime); +#endif - // TODO: Not currently supported - // pxr::VtValue diffuse; - // light_prim.GetDiffuseAttr().Get(&diffuse, motionSampleTime); + /* TODO(makowalsk): Not currently supported */ +#if 0 + pxr::VtValue diffuse; + light_prim.GetDiffuseAttr().Get(&diffuse, motionSampleTime); +#endif pxr::VtValue specular; light_prim.GetSpecularAttr().Get(&specular, motionSampleTime); @@ -97,19 +101,23 @@ void USDLightReader::read_object_data(Main *bmain, const double motionSampleTime pxr::VtValue color; light_prim.GetColorAttr().Get(&color, motionSampleTime); - // Calling UncheckedGet() to silence compiler warning. + /* Calling UncheckedGet() to silence compiler warning. */ pxr::GfVec3f color_vec = color.UncheckedGet<pxr::GfVec3f>(); blight->r = color_vec[0]; blight->g = color_vec[1]; blight->b = color_vec[2]; - // TODO: Not currently supported - // pxr::VtValue use_color_temp; - // light_prim.GetEnableColorTemperatureAttr().Get(&use_color_temp, motionSampleTime); - - // TODO: Not currently supported - // pxr::VtValue color_temp; - // light_prim.GetColorTemperatureAttr().Get(&color_temp, motionSampleTime); + /* TODO(makowalski): Not currently supported. */ +#if 0 + pxr::VtValue use_color_temp; + light_prim.GetEnableColorTemperatureAttr().Get(&use_color_temp, motionSampleTime); +#endif + + /* TODO(makowalski): Not currently supported. */ +#if 0 + pxr::VtValue color_temp; + light_prim.GetColorTemperatureAttr().Get(&color_temp, motionSampleTime); +#endif switch (blight->type) { case LA_AREA: diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index a99e65f5792..e3a4acde354 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -38,7 +38,7 @@ namespace usdtokens { -// Parameter names +/* Parameter names. */ static const pxr::TfToken a("a", pxr::TfToken::Immortal); static const pxr::TfToken b("b", pxr::TfToken::Immortal); static const pxr::TfToken clearcoat("clearcoat", pxr::TfToken::Immortal); @@ -63,11 +63,11 @@ static const pxr::TfToken specularColor("specularColor", pxr::TfToken::Immortal) static const pxr::TfToken st("st", pxr::TfToken::Immortal); static const pxr::TfToken varname("varname", pxr::TfToken::Immortal); -// Color space names +/* Color space names. */ static const pxr::TfToken raw("raw", pxr::TfToken::Immortal); static const pxr::TfToken RAW("RAW", pxr::TfToken::Immortal); -// USD shader names. +/* USD shader names. */ static const pxr::TfToken UsdPreviewSurface("UsdPreviewSurface", pxr::TfToken::Immortal); static const pxr::TfToken UsdPrimvarReader_float2("UsdPrimvarReader_float2", pxr::TfToken::Immortal); @@ -109,9 +109,9 @@ static void link_nodes( nodeAddLink(ntree, source, source_socket, dest, dest_socket); } -// Returns true if the given shader may have opacity < 1.0, based -// on heuristics. Also returns the shader's opacityThreshold input -// in r_opacity_threshold, if this input has an authored value. +/* Returns true if the given shader may have opacity < 1.0, based + * on heuristics. Also returns the shader's opacityThreshold input + * in r_opacity_threshold, if this input has an authored value. */ static bool needs_blend(const pxr::UsdShadeShader &usd_shader, float &r_opacity_threshold) { if (!usd_shader) { @@ -229,9 +229,9 @@ namespace blender::io::usd { namespace { -// Compute the x- and y-coordinates for placing a new node in an unoccupied region of -// the column with the given index. Returns the coordinates in r_locx and r_locy and -// updates the column-occupancy information in r_ctx. +/* Compute the x- and y-coordinates for placing a new node in an unoccupied region of + * the column with the given index. Returns the coordinates in r_locx and r_locy and + * updates the column-occupancy information in r_ctx. */ void compute_node_loc(const int column, float &r_locx, float &r_locy, NodePlacementContext &r_ctx) { r_locx = r_ctx.origx - column * r_ctx.horizontal_step; @@ -242,12 +242,12 @@ void compute_node_loc(const int column, float &r_locx, float &r_locy, NodePlacem r_locy = r_ctx.origy - r_ctx.column_offsets[column]; - // Record the y-offset of the occupied region in - // the column, including padding. + /* Record the y-offset of the occupied region in + * the column, including padding. */ r_ctx.column_offsets[column] += r_ctx.vertical_step + 10.0f; } -} // namespace +} // End anonymous namespace. USDMaterialReader::USDMaterialReader(const USDImportParams ¶ms, Main *bmain) : params_(params), bmain_(bmain) @@ -508,20 +508,20 @@ void USDMaterialReader::follow_connection(const pxr::UsdShadeInput &usd_input, if (strcmp(dest_socket_name, "Normal") == 0) { - // The normal texture input requires creating a normal map node. + /* The normal texture input requires creating a normal map node. */ float locx = 0.0f; float locy = 0.0f; compute_node_loc(column + 1, locx, locy, r_ctx); 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. + /* 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. */ - // Connect the Normal Map to the Normal input. + /* Connect the Normal Map to the Normal input. */ link_nodes(ntree, normal_map, "Normal", dest_node, "Normal"); - // Now, create the Texture Image node input to the Normal Map "Color" input. + /* Now, create the Texture Image node input to the Normal Map "Color" input. */ convert_usd_uv_texture( source_shader, source_name, normal_map, "Color", ntree, column + 2, r_ctx); } @@ -552,7 +552,7 @@ void USDMaterialReader::convert_usd_uv_texture(const pxr::UsdShadeShader &usd_sh float locy = 0.0f; compute_node_loc(column, locx, locy, r_ctx); - // Create the Texture Image node. + /* Create the Texture Image node. */ bNode *tex_image = add_node(nullptr, ntree, SH_NODE_TEX_IMAGE, locx, locy); if (!tex_image) { @@ -561,17 +561,17 @@ void USDMaterialReader::convert_usd_uv_texture(const pxr::UsdShadeShader &usd_sh return; } - // Load the texture image. + /* Load the texture image. */ load_tex_image(usd_shader, tex_image); - // Connect to destination node input. + /* Connect to destination node input. */ - // Get the source socket name. + /* Get the source socket name. */ std::string source_socket_name = usd_source_name == usdtokens::a ? "Alpha" : "Color"; link_nodes(ntree, tex_image, source_socket_name.c_str(), dest_node, dest_socket_name); - // Connect the texture image node "Vector" input. + /* Connect the texture image node "Vector" input. */ if (pxr::UsdShadeInput st_input = usd_shader.GetInput(usdtokens::st)) { set_node_input(st_input, tex_image, "Vector", ntree, column, r_ctx); } @@ -586,7 +586,7 @@ void USDMaterialReader::load_tex_image(const pxr::UsdShadeShader &usd_shader, return; } - // Try to load the texture image. + /* Try to load the texture image. */ pxr::UsdShadeInput file_input = usd_shader.GetInput(usdtokens::file); if (!file_input) { @@ -620,10 +620,10 @@ void USDMaterialReader::load_tex_image(const pxr::UsdShadeShader &usd_shader, tex_image->id = &image->id; - // Set texture color space. - // TODO(makowalski): For now, just checking for RAW color space, - // assuming sRGB otherwise, but more complex logic might be - // required if the color space is "auto". + /* Set texture color space. + * TODO(makowalski): For now, just checking for RAW color space, + * assuming sRGB otherwise, but more complex logic might be + * required if the color space is "auto". */ pxr::TfToken color_space = get_source_color_space(usd_shader); @@ -657,7 +657,7 @@ void USDMaterialReader::convert_usd_primvar_reader_float2( float locy = 0.0f; compute_node_loc(column, locx, locy, r_ctx); - // Create the UV Map node. + /* Create the UV Map node. */ bNode *uv_map = add_node(nullptr, ntree, SH_NODE_UVMAP, locx, locy); if (!uv_map) { @@ -666,7 +666,7 @@ void USDMaterialReader::convert_usd_primvar_reader_float2( return; } - // Set the texmap name. + /* Set the texmap name. */ pxr::UsdShadeInput varname_input = usd_shader.GetInput(usdtokens::varname); if (varname_input) { pxr::VtValue varname_val; @@ -679,7 +679,7 @@ void USDMaterialReader::convert_usd_primvar_reader_float2( } } - // Connect to destination node input. + /* Connect to destination node input. */ link_nodes(ntree, uv_map, "UV", dest_node, dest_socket_name); } diff --git a/source/blender/io/usd/intern/usd_reader_material.h b/source/blender/io/usd/intern/usd_reader_material.h index 860a4722cdf..b9db535c6f7 100644 --- a/source/blender/io/usd/intern/usd_reader_material.h +++ b/source/blender/io/usd/intern/usd_reader_material.h @@ -29,10 +29,10 @@ struct bNodeTree; namespace blender::io::usd { -// Helper struct used when arranging nodes in columns, keeping track the -// occupancy information for a given column. I.e., for column n, -// column_offsets[n] is the y-offset (from top to bottom) of the occupied -// region in that column. +/* Helper struct used when arranging nodes in columns, keeping track the + * occupancy information for a given column. I.e., for column n, + * column_offsets[n] is the y-offset (from top to bottom) of the occupied + * region in that column. */ struct NodePlacementContext { float origx; float origy; diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 00122ac2b66..ce2572179e6 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -47,7 +47,7 @@ #include <iostream> namespace usdtokens { -// Materials +/* Materials */ static const pxr::TfToken st("st", pxr::TfToken::Immortal); static const pxr::TfToken UVMap("UVMap", pxr::TfToken::Immortal); static const pxr::TfToken Cd("Cd", pxr::TfToken::Immortal); @@ -56,13 +56,13 @@ static const pxr::TfToken normalsPrimvar("normals", pxr::TfToken::Immortal); } // namespace usdtokens namespace utils { -// Very similar to abc mesh utils +/* Very similar to abc mesh utils. */ static void build_mat_map(const Main *bmain, std::map<std::string, Material *> &mat_map) { Material *material = static_cast<Material *>(bmain->materials.first); for (; material; material = static_cast<Material *>(material->id.next)) { - // We have to do this because the stored material name is coming directly from usd + /* We have to do this because the stored material name is coming directly from usd. */ mat_map[pxr::TfMakeValidIdentifier(material->id.name + 2)] = material; } } @@ -251,7 +251,7 @@ bool USDMeshReader::topology_changed(Mesh * /* existing_mesh */, const double mo faceVertCountsAttr.Get(&face_counts_, motionSampleTime); pointsAttr.Get(&positions_, motionSampleTime); - // If 'normals' and 'primvars:normals' are both specified, the latter has precedence. + /* If 'normals' and 'primvars:normals' are both specified, the latter has precedence. */ pxr::UsdGeomPrimvar primvar = mesh_prim_.GetPrimvar(usdtokens::normalsPrimvar); if (primvar.HasValue()) { primvar.ComputeFlattened(&normals_, motionSampleTime); @@ -333,7 +333,7 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo pxr::TfToken uv_token; - // If first time seeing uv token, store in map of <layer->uid, TfToken> + /* If first time seeing uv token, store in map of <layer->uid, TfToken> */ if (uv_token_map_.find(layer_name) == uv_token_map_.end()) { uv_token = pxr::TfToken(layer_name); uv_token_map_.insert(std::make_pair(layer_name, uv_token)); @@ -342,17 +342,17 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo uv_token = uv_token_map_.at(layer_name); } - // Early out if no token found, this should never happen + /* Early out if no token found, this should never happen */ if (uv_token.IsEmpty()) { continue; } - // Early out if not first load and uvs arent animated + /* Early out if not first load and uvs arent animated. */ if (!load_uvs && primvar_varying_map_.find(uv_token) != primvar_varying_map_.end() && !primvar_varying_map_.at(uv_token)) { continue; } - // Early out if mesh doesn't have primvar + /* Early out if mesh doesn't have primvar. */ if (!mesh_prim_.HasPrimvar(uv_token)) { continue; } @@ -377,12 +377,12 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo continue; } - // Early out if mismatched layer sizes + /* Early out if mismatched layer sizes. */ if (layer_idx > uv_primvars.size()) { continue; } - // Early out if no uvs loaded + /* Early out if no uvs loaded. */ if (uv_primvars[layer_idx].uvs.empty()) { continue; } @@ -391,13 +391,12 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo if (!(sample.interpolation == pxr::UsdGeomTokens->faceVarying || sample.interpolation == pxr::UsdGeomTokens->vertex)) { - /* Shouldn't happen. */ std::cerr << "WARNING: unexpected interpolation type " << sample.interpolation << " for uv " << layer->name << std::endl; continue; } - // For Vertex interpolation, use the vertex index. + /* For Vertex interpolation, use the vertex index. */ int usd_uv_index = sample.interpolation == pxr::UsdGeomTokens->vertex ? mesh->mloop[loop_index].v : loop_index; @@ -487,7 +486,8 @@ void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime) for (int j = 0; j < poly->totloop; ++j) { int loop_index = poly->loopstart + j; - int usd_index = 0; // Default for constant varying interpolation. + /* Default for constant varying interpolation. */ + int usd_index = 0; if (interp == pxr::UsdGeomTokens->vertex) { usd_index = mesh->mloop[loop_index].v; @@ -502,7 +502,7 @@ void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime) } } else if (interp == pxr::UsdGeomTokens->uniform) { - // Uniform varying uses the poly index. + /* Uniform varying uses the poly index. */ usd_index = i; } @@ -549,7 +549,7 @@ void USDMeshReader::process_normals_face_varying(Mesh *mesh) return; } - // Check for normals count mismatches to prevent crashes. + /* Check for normals count mismatches to prevent crashes. */ if (normals_.size() != mesh->totloop) { std::cerr << "WARNING: loop normal count mismatch for mesh " << mesh->id.name << std::endl; BKE_mesh_calc_normals(mesh); @@ -587,7 +587,7 @@ void USDMeshReader::process_normals_face_varying(Mesh *mesh) MEM_freeN(lnors); } -// Set USD uniform (per-face) normals as Blender loop normals. +/* Set USD uniform (per-face) normals as Blender loop normals. */ void USDMeshReader::process_normals_uniform(Mesh *mesh) { if (normals_.empty()) { @@ -595,7 +595,7 @@ void USDMeshReader::process_normals_uniform(Mesh *mesh) return; } - // Check for normals count mismatches to prevent crashes. + /* Check for normals count mismatches to prevent crashes. */ if (normals_.size() != mesh->totpoly) { std::cerr << "WARNING: uniform normal count mismatch for mesh " << mesh->id.name << std::endl; BKE_mesh_calc_normals(mesh); @@ -628,9 +628,9 @@ void USDMeshReader::read_mesh_sample(ImportSettings *settings, const double motionSampleTime, const bool new_mesh) { - // Note that for new meshes we always want to read verts and polys, - // regradless of the value of the read_flag, to avoid a crash downstream - // in code that expect this data to be there. + /* Note that for new meshes we always want to read verts and polys, + * regradless of the value of the read_flag, to avoid a crash downstream + * in code that expect this data to be there. */ if (new_mesh || (settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0) { for (int i = 0; i < positions_.size(); i++) { @@ -650,15 +650,15 @@ void USDMeshReader::read_mesh_sample(ImportSettings *settings, process_normals_uniform(mesh); } else { - // Default + /* Default */ BKE_mesh_calc_normals(mesh); } } - // Process point normals after reading polys. This - // is important in the case where the normals are empty - // and we invoke BKE_mesh_calc_normals(mesh), which requires - // edges to be defined. + /* Process point normals after reading polys. This + * is important in the case where the normals are empty + * and we invoke BKE_mesh_calc_normals(mesh), which requires + * edges to be defined. */ if ((settings->read_flag & MOD_MESHSEQ_READ_VERT) != 0 && normal_interpolation_ == pxr::UsdGeomTokens->vertex) { process_normals_vertex_varying(mesh); diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h index fd19af5f505..7a2d1b58c4d 100644 --- a/source/blender/io/usd/usd.h +++ b/source/blender/io/usd/usd.h @@ -92,7 +92,7 @@ bool USD_import(struct bContext *C, int USD_get_version(void); -// ----- USD Import and Mesh Cache interface +/* USD Import and Mesh Cache interface. */ struct CacheArchiveHandle *USD_create_handle(struct Main *bmain, const char *filename, |