USD import fix: set active mesh color.

Fixed a bug where the active color wasn't being set
on imported meshes, resulting in no colors displaying
in the viewport.

This bug has been in the code for a long time. However,
the colors have been displaying correctly until recently,
so this issue wasn't previously apparent.

Also, changed custom color data name from "displayColors"
to "displayColor", to match the actual USD primvar name.
(This was a typo in the original code.)

Note that pull request

https://projects.blender.org/blender/blender/pulls/104542

addresses other issues in the color import code (e.g.,
converting all color primvars and not just "displayColor",
avoiding hard-coding of attribute names, handling all
iterpolation types, etc.).

However, the current commit is meant as a short term fix
to a regression, where the "displayColor" attribute does
not render in the viewport at all, until the above pull
can be merged.
This commit is contained in:
Michael Kowalski
2023-03-20 11:14:56 -04:00
committed by Bastien Montagne
parent a60f651502
commit e9db83a7b0

View File

@@ -458,10 +458,10 @@ void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime)
return;
}
void *cd_ptr = add_customdata_cb(mesh, "displayColors", CD_PROP_BYTE_COLOR);
void *cd_ptr = add_customdata_cb(mesh, "displayColor", CD_PROP_BYTE_COLOR);
if (!cd_ptr) {
std::cerr << "WARNING: Couldn't add displayColors custom data.\n";
std::cerr << "WARNING: Couldn't add displayColor custom data.\n";
return;
}
@@ -504,6 +504,8 @@ void USDMeshReader::read_colors(Mesh *mesh, const double motionSampleTime)
colors[loop_index].a = unit_float_to_uchar_clamp(1.0);
}
}
BKE_id_attributes_active_color_set(&mesh->id, "displayColor");
}
void USDMeshReader::read_vertex_creases(Mesh *mesh, const double motionSampleTime)