Cleanup: Standardize CurvesGeometry naming in Alembic and USD
- Curves data-block is called "curves_id" - CurvesGeometry is called "curves"
This commit is contained in:
@@ -136,15 +136,15 @@ static CurveType get_curve_type(const Alembic::AbcGeom::BasisType basis)
|
||||
return CURVE_TYPE_POLY;
|
||||
}
|
||||
|
||||
static bool curves_topology_changed(const bke::CurvesGeometry &geometry,
|
||||
static bool curves_topology_changed(const bke::CurvesGeometry &curves,
|
||||
Span<int> preprocessed_offsets)
|
||||
{
|
||||
/* Offsets have an extra element. */
|
||||
if (geometry.curve_num != preprocessed_offsets.size() - 1) {
|
||||
if (curves.curve_num != preprocessed_offsets.size() - 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const Span<int> offsets = geometry.offsets();
|
||||
const Span<int> offsets = curves.offsets();
|
||||
for (const int i_curve : preprocessed_offsets.index_range()) {
|
||||
if (offsets[i_curve] != preprocessed_offsets[i_curve]) {
|
||||
return true;
|
||||
@@ -323,13 +323,12 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
|
||||
}
|
||||
}
|
||||
|
||||
void AbcCurveReader::read_curves_sample(Curves *curves,
|
||||
void AbcCurveReader::read_curves_sample(Curves *curves_id,
|
||||
const ICurvesSchema &schema,
|
||||
const ISampleSelector &sample_sel)
|
||||
{
|
||||
std::optional<PreprocessedSampleData> opt_preprocess = preprocess_sample(
|
||||
m_iobject.getFullName(), schema, sample_sel);
|
||||
|
||||
if (!opt_preprocess) {
|
||||
return;
|
||||
}
|
||||
@@ -339,42 +338,42 @@ void AbcCurveReader::read_curves_sample(Curves *curves,
|
||||
const int point_count = data.offset_in_blender.last();
|
||||
const int curve_count = data.offset_in_blender.size() - 1;
|
||||
|
||||
bke::CurvesGeometry &geometry = curves->geometry.wrap();
|
||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
|
||||
if (curves_topology_changed(geometry, data.offset_in_blender)) {
|
||||
geometry.resize(point_count, curve_count);
|
||||
geometry.offsets_for_write().copy_from(data.offset_in_blender);
|
||||
if (curves_topology_changed(curves, data.offset_in_blender)) {
|
||||
curves.resize(point_count, curve_count);
|
||||
curves.offsets_for_write().copy_from(data.offset_in_blender);
|
||||
}
|
||||
|
||||
geometry.fill_curve_types(data.curve_type);
|
||||
curves.fill_curve_types(data.curve_type);
|
||||
|
||||
if (data.curve_type != CURVE_TYPE_POLY) {
|
||||
geometry.resolution_for_write().fill(get_curve_resolution(schema, sample_sel));
|
||||
curves.resolution_for_write().fill(get_curve_resolution(schema, sample_sel));
|
||||
}
|
||||
|
||||
MutableSpan<float3> curves_positions = geometry.positions_for_write();
|
||||
for (const int i_curve : geometry.curves_range()) {
|
||||
MutableSpan<float3> curves_positions = curves.positions_for_write();
|
||||
for (const int i_curve : curves.curves_range()) {
|
||||
int position_offset = data.offset_in_alembic[i_curve];
|
||||
for (const int i_point : geometry.points_by_curve()[i_curve]) {
|
||||
for (const int i_point : curves.points_by_curve()[i_curve]) {
|
||||
const Imath::V3f &pos = (*data.positions)[position_offset++];
|
||||
copy_zup_from_yup(curves_positions[i_point], pos.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (data.do_cyclic) {
|
||||
geometry.cyclic_for_write().copy_from(data.curves_cyclic);
|
||||
geometry.handle_types_left_for_write().fill(BEZIER_HANDLE_AUTO);
|
||||
geometry.handle_types_right_for_write().fill(BEZIER_HANDLE_AUTO);
|
||||
curves.cyclic_for_write().copy_from(data.curves_cyclic);
|
||||
curves.handle_types_left_for_write().fill(BEZIER_HANDLE_AUTO);
|
||||
curves.handle_types_right_for_write().fill(BEZIER_HANDLE_AUTO);
|
||||
}
|
||||
|
||||
if (data.radii) {
|
||||
bke::SpanAttributeWriter<float> radii =
|
||||
geometry.attributes_for_write().lookup_or_add_for_write_span<float>(
|
||||
"radius", bke::AttrDomain::Point);
|
||||
curves.attributes_for_write().lookup_or_add_for_write_span<float>("radius",
|
||||
bke::AttrDomain::Point);
|
||||
|
||||
for (const int i_curve : geometry.curves_range()) {
|
||||
for (const int i_curve : curves.curves_range()) {
|
||||
int position_offset = data.offset_in_alembic[i_curve];
|
||||
for (const int i_point : geometry.points_by_curve()[i_curve]) {
|
||||
for (const int i_point : curves.points_by_curve()[i_curve]) {
|
||||
radii.span[i_point] = (*data.radii)[position_offset++];
|
||||
}
|
||||
}
|
||||
@@ -383,14 +382,14 @@ void AbcCurveReader::read_curves_sample(Curves *curves,
|
||||
}
|
||||
|
||||
if (data.curve_type == CURVE_TYPE_NURBS) {
|
||||
geometry.nurbs_orders_for_write().copy_from(data.curves_orders);
|
||||
curves.nurbs_orders_for_write().copy_from(data.curves_orders);
|
||||
|
||||
if (data.weights) {
|
||||
MutableSpan<float> curves_weights = geometry.nurbs_weights_for_write();
|
||||
MutableSpan<float> curves_weights = curves.nurbs_weights_for_write();
|
||||
Span<float> data_weights_span = {data.weights->get(), int64_t(data.weights->size())};
|
||||
for (const int i_curve : geometry.curves_range()) {
|
||||
for (const int i_curve : curves.curves_range()) {
|
||||
const int alembic_offset = data.offset_in_alembic[i_curve];
|
||||
const IndexRange points = geometry.points_by_curve()[i_curve];
|
||||
const IndexRange points = curves.points_by_curve()[i_curve];
|
||||
curves_weights.slice(points).copy_from(
|
||||
data_weights_span.slice(alembic_offset, points.size()));
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class AbcCurveReader final : public AbcObjectReader {
|
||||
float velocity_scale,
|
||||
const char **err_str) override;
|
||||
|
||||
void read_curves_sample(Curves *curves,
|
||||
void read_curves_sample(Curves *curves_id,
|
||||
const Alembic::AbcGeom::ICurvesSchema &schema,
|
||||
const Alembic::Abc::ISampleSelector &sample_selector);
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ static int point_count(int usdCount, CurveType curve_type, bool is_cyclic)
|
||||
if (curve_type == CURVE_TYPE_BEZIER) {
|
||||
return bezier_point_count(usdCount, is_cyclic);
|
||||
}
|
||||
return usdCount;
|
||||
return usdCount;
|
||||
}
|
||||
|
||||
/** Return the sum of the values of each element in `usdCounts`. This is used for precomputing the
|
||||
@@ -79,22 +79,22 @@ static void add_bezier_control_point(int cp,
|
||||
}
|
||||
|
||||
/** Returns true if the number of curves or the number of curve points in each curve differ. */
|
||||
static bool curves_topology_changed(const CurvesGeometry &geometry,
|
||||
static bool curves_topology_changed(const bke::CurvesGeometry &curves,
|
||||
const pxr::VtIntArray &usdCounts,
|
||||
CurveType curve_type,
|
||||
int expected_total_point_num,
|
||||
bool is_cyclic)
|
||||
{
|
||||
if (geometry.curve_num != usdCounts.size()) {
|
||||
if (curves.curves_num() != usdCounts.size()) {
|
||||
return true;
|
||||
}
|
||||
if (geometry.point_num != expected_total_point_num) {
|
||||
if (curves.points_num() != expected_total_point_num) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const int curve_idx : IndexRange(geometry.curve_num)) {
|
||||
const int expected_curve_point_num = point_count(usdCounts[curve_idx], curve_type, is_cyclic);
|
||||
const int current_curve_point_num = geometry.curve_offsets[curve_idx];
|
||||
for (const int curve : curves.curves_range()) {
|
||||
const int expected_curve_point_num = point_count(usdCounts[curve], curve_type, is_cyclic);
|
||||
const int current_curve_point_num = curves.curve_offsets[curve];
|
||||
|
||||
if (current_curve_point_num != expected_curve_point_num) {
|
||||
return true;
|
||||
@@ -141,7 +141,7 @@ void USDCurvesReader::read_object_data(Main *bmain, double motionSampleTime)
|
||||
USDXformReader::read_object_data(bmain, motionSampleTime);
|
||||
}
|
||||
|
||||
void USDCurvesReader::read_curve_sample(Curves *cu, const double motionSampleTime)
|
||||
void USDCurvesReader::read_curve_sample(Curves *curves_id, const double motionSampleTime)
|
||||
{
|
||||
curve_prim_ = pxr::UsdGeomBasisCurves(prim_);
|
||||
if (!curve_prim_) {
|
||||
@@ -179,33 +179,33 @@ void USDCurvesReader::read_curve_sample(Curves *cu, const double motionSampleTim
|
||||
const int num_points = accumulate_point_count(usdCounts, curve_type, is_cyclic);
|
||||
const int default_resolution = 6;
|
||||
|
||||
bke::CurvesGeometry &geometry = cu->geometry.wrap();
|
||||
if (curves_topology_changed(geometry, usdCounts, curve_type, num_points, is_cyclic)) {
|
||||
geometry.resize(num_points, num_subcurves);
|
||||
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
|
||||
if (curves_topology_changed(curves, usdCounts, curve_type, num_points, is_cyclic)) {
|
||||
curves.resize(num_points, num_subcurves);
|
||||
}
|
||||
|
||||
geometry.fill_curve_types(curve_type);
|
||||
geometry.resolution_for_write().fill(default_resolution);
|
||||
curves.fill_curve_types(curve_type);
|
||||
curves.resolution_for_write().fill(default_resolution);
|
||||
|
||||
if (is_cyclic) {
|
||||
geometry.cyclic_for_write().fill(true);
|
||||
curves.cyclic_for_write().fill(true);
|
||||
}
|
||||
|
||||
if (curve_type == CURVE_TYPE_NURBS) {
|
||||
const int8_t curve_order = type == pxr::UsdGeomTokens->cubic ? 4 : 2;
|
||||
geometry.nurbs_orders_for_write().fill(curve_order);
|
||||
curves.nurbs_orders_for_write().fill(curve_order);
|
||||
}
|
||||
|
||||
MutableSpan<int> offsets = geometry.offsets_for_write();
|
||||
MutableSpan<float3> positions = geometry.positions_for_write();
|
||||
MutableSpan<int> offsets = curves.offsets_for_write();
|
||||
MutableSpan<float3> positions = curves.positions_for_write();
|
||||
|
||||
/* Bezier curves require care in filing out their left/right handles. */
|
||||
if (type == pxr::UsdGeomTokens->cubic && basis == pxr::UsdGeomTokens->bezier) {
|
||||
geometry.handle_types_left_for_write().fill(BEZIER_HANDLE_ALIGN);
|
||||
geometry.handle_types_right_for_write().fill(BEZIER_HANDLE_ALIGN);
|
||||
curves.handle_types_left_for_write().fill(BEZIER_HANDLE_ALIGN);
|
||||
curves.handle_types_right_for_write().fill(BEZIER_HANDLE_ALIGN);
|
||||
|
||||
MutableSpan<float3> handles_right = geometry.handle_positions_right_for_write();
|
||||
MutableSpan<float3> handles_left = geometry.handle_positions_left_for_write();
|
||||
MutableSpan<float3> handles_right = curves.handle_positions_right_for_write();
|
||||
MutableSpan<float3> handles_left = curves.handle_positions_left_for_write();
|
||||
Span<pxr::GfVec3f> points{usdPoints.data(), int64_t(usdPoints.size())};
|
||||
|
||||
int usd_point_offset = 0;
|
||||
@@ -239,15 +239,15 @@ void USDCurvesReader::read_curve_sample(Curves *cu, const double motionSampleTim
|
||||
offset += num_verts;
|
||||
}
|
||||
|
||||
for (const int i_point : geometry.points_range()) {
|
||||
for (const int i_point : curves.points_range()) {
|
||||
positions[i_point] = to_float3(usdPoints[i_point]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!usdWidths.empty()) {
|
||||
bke::SpanAttributeWriter<float> radii =
|
||||
geometry.attributes_for_write().lookup_or_add_for_write_span<float>(
|
||||
"radius", bke::AttrDomain::Point);
|
||||
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
|
||||
bke::SpanAttributeWriter<float> radii = attributes.lookup_or_add_for_write_span<float>(
|
||||
"radius", bke::AttrDomain::Point);
|
||||
|
||||
pxr::TfToken widths_interp = curve_prim_.GetWidthsInterpolation();
|
||||
if (widths_interp == pxr::UsdGeomTokens->constant) {
|
||||
@@ -277,7 +277,7 @@ void USDCurvesReader::read_curve_sample(Curves *cu, const double motionSampleTim
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const int i_point : geometry.points_range()) {
|
||||
for (const int i_point : curves.points_range()) {
|
||||
radii.span[i_point] = usdWidths[i_point] / 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class USDCurvesReader : public USDGeomReader {
|
||||
void create_object(Main *bmain, double motionSampleTime) override;
|
||||
void read_object_data(Main *bmain, double motionSampleTime) override;
|
||||
|
||||
void read_curve_sample(Curves *cu, double motionSampleTime);
|
||||
void read_curve_sample(Curves *curves_id, double motionSampleTime);
|
||||
|
||||
void read_geometry(bke::GeometrySet &geometry_set,
|
||||
USDMeshReadParams params,
|
||||
|
||||
Reference in New Issue
Block a user