Cleanup: Simplify if statements, clang tidy
This commit is contained in:
parent
228f7f1c85
commit
bb7e3c2b56
|
@ -1187,8 +1187,7 @@ class NormalAttributeProvider final : public BuiltinAttributeProvider {
|
|||
static ComponentAttributeProviders create_attribute_providers_for_mesh()
|
||||
{
|
||||
static auto update_custom_data_pointers = [](GeometryComponent &component) {
|
||||
Mesh *mesh = get_mesh_from_component_for_write(component);
|
||||
if (mesh != nullptr) {
|
||||
if (Mesh *mesh = get_mesh_from_component_for_write(component)) {
|
||||
BKE_mesh_update_customdata_pointers(mesh, false);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -125,8 +125,7 @@ static ComponentAttributeProviders create_attribute_providers_for_point_cloud()
|
|||
{
|
||||
static auto update_custom_data_pointers = [](GeometryComponent &component) {
|
||||
PointCloudComponent &pointcloud_component = static_cast<PointCloudComponent &>(component);
|
||||
PointCloud *pointcloud = pointcloud_component.get_for_write();
|
||||
if (pointcloud != nullptr) {
|
||||
if (PointCloud *pointcloud = pointcloud_component.get_for_write()) {
|
||||
BKE_pointcloud_update_customdata_pointers(pointcloud);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -176,20 +176,16 @@ Vector<const GeometryComponent *> GeometrySet::get_components_for_read() const
|
|||
bool GeometrySet::compute_boundbox_without_instances(float3 *r_min, float3 *r_max) const
|
||||
{
|
||||
bool have_minmax = false;
|
||||
const PointCloud *pointcloud = this->get_pointcloud_for_read();
|
||||
if (pointcloud != nullptr) {
|
||||
if (const PointCloud *pointcloud = this->get_pointcloud_for_read()) {
|
||||
have_minmax |= BKE_pointcloud_minmax(pointcloud, *r_min, *r_max);
|
||||
}
|
||||
const Mesh *mesh = this->get_mesh_for_read();
|
||||
if (mesh != nullptr) {
|
||||
if (const Mesh *mesh = this->get_mesh_for_read()) {
|
||||
have_minmax |= BKE_mesh_wrapper_minmax(mesh, *r_min, *r_max);
|
||||
}
|
||||
const Volume *volume = this->get_volume_for_read();
|
||||
if (volume != nullptr) {
|
||||
if (const Volume *volume = this->get_volume_for_read()) {
|
||||
have_minmax |= BKE_volume_min_max(volume, *r_min, *r_max);
|
||||
}
|
||||
const Curves *curves = this->get_curves_for_read();
|
||||
if (curves != nullptr) {
|
||||
if (const Curves *curves = this->get_curves_for_read()) {
|
||||
std::unique_ptr<CurveEval> curve = curves_to_curve_eval(*curves);
|
||||
/* Using the evaluated positions is somewhat arbitrary, but it is probably expected. */
|
||||
have_minmax |= curve->bounds_min_max(*r_min, *r_max, true);
|
||||
|
|
|
@ -776,32 +776,27 @@ static void make_duplis_geometry_set_impl(const DupliContext *ctx,
|
|||
{
|
||||
int component_index = 0;
|
||||
if (ctx->object->type != OB_MESH || geometry_set_is_instance) {
|
||||
const Mesh *mesh = geometry_set.get_mesh_for_read();
|
||||
if (mesh != nullptr) {
|
||||
if (const Mesh *mesh = geometry_set.get_mesh_for_read()) {
|
||||
DupliObject *dupli = make_dupli(ctx, ctx->object, parent_transform, component_index++);
|
||||
dupli->ob_data = (ID *)mesh;
|
||||
}
|
||||
}
|
||||
if (ctx->object->type != OB_VOLUME || geometry_set_is_instance) {
|
||||
const Volume *volume = geometry_set.get_volume_for_read();
|
||||
if (volume != nullptr) {
|
||||
if (const Volume *volume = geometry_set.get_volume_for_read()) {
|
||||
DupliObject *dupli = make_dupli(ctx, ctx->object, parent_transform, component_index++);
|
||||
dupli->ob_data = (ID *)volume;
|
||||
}
|
||||
}
|
||||
if (!ELEM(ctx->object->type, OB_CURVES_LEGACY, OB_FONT) || geometry_set_is_instance) {
|
||||
const CurveComponent *curve_component = geometry_set.get_component_for_read<CurveComponent>();
|
||||
if (curve_component != nullptr) {
|
||||
const Curve *curve = curve_component->get_curve_for_render();
|
||||
if (curve != nullptr) {
|
||||
if (const CurveComponent *component = geometry_set.get_component_for_read<CurveComponent>()) {
|
||||
if (const Curve *curve = component->get_curve_for_render()) {
|
||||
DupliObject *dupli = make_dupli(ctx, ctx->object, parent_transform, component_index++);
|
||||
dupli->ob_data = (ID *)curve;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctx->object->type != OB_POINTCLOUD || geometry_set_is_instance) {
|
||||
const PointCloud *pointcloud = geometry_set.get_pointcloud_for_read();
|
||||
if (pointcloud != nullptr) {
|
||||
if (const PointCloud *pointcloud = geometry_set.get_pointcloud_for_read()) {
|
||||
DupliObject *dupli = make_dupli(ctx, ctx->object, parent_transform, component_index++);
|
||||
dupli->ob_data = (ID *)pointcloud;
|
||||
}
|
||||
|
|
|
@ -1225,7 +1225,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
}
|
||||
|
||||
/* Active channels root pointer. */
|
||||
if (ed->displayed_channels == old_displayed_channels || ed->displayed_channels == NULL) {
|
||||
if (ed->displayed_channels == old_displayed_channels || ed->displayed_channels == nullptr) {
|
||||
ed->displayed_channels = &ed->channels;
|
||||
}
|
||||
else {
|
||||
|
@ -1260,7 +1260,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
|
|||
}
|
||||
}
|
||||
|
||||
if (ms->old_channels == old_displayed_channels || ms->old_channels == NULL) {
|
||||
if (ms->old_channels == old_displayed_channels || ms->old_channels == nullptr) {
|
||||
ms->old_channels = &ed->channels;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -28,8 +28,7 @@ static void node_geo_exec(GeoNodeExecParams params)
|
|||
GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
|
||||
|
||||
geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
|
||||
Mesh *mesh = geometry_set.get_mesh_for_write();
|
||||
if (mesh != nullptr) {
|
||||
if (Mesh *mesh = geometry_set.get_mesh_for_write()) {
|
||||
for (const int i : IndexRange(mesh->totcol)) {
|
||||
if (mesh->mat[i] == old_material) {
|
||||
mesh->mat[i] = new_material;
|
||||
|
|
Loading…
Reference in New Issue