Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hdmitsuba/curves.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ void HdMitsubaCurves::Sync(HdSceneDelegate* sceneDelegate,
// Pack control points [x, y, z, r] (lazy-evaluating widths based on layout)
if (widths_.size() == points_.size()) {
spec.control_points =
PackControlPoints(points_, [&](size_t i) { return widths_[i]; });
PackControlPoints(points_, [&](size_t i) { return widths_[i] * 0.5f; });
} else if (widths_.size() == 1) {
float r = widths_[0];
float r = widths_[0] * 0.5f;
spec.control_points =
PackControlPoints(points_, [&](size_t /*i*/) { return r; });
} else {
float uniform_radius = CalculateMeanWidth(widths_);
float uniform_radius = CalculateMeanWidth(widths_) * 0.5f;
spec.control_points = PackControlPoints(
points_, [&](size_t /*i*/) { return uniform_radius; });
}
Expand Down
18 changes: 13 additions & 5 deletions usd_mitsuba/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@ def _convert_curves(
time: Usd.TimeCode = Usd.TimeCode.Default(),
) -> mi.Object:
"""Handles a curves prim and returns the Mitsuba curve object."""
curve_prim = UsdGeom.BasisCurves(prim)
curve_prim = UsdGeom.Curves(prim)
curve_points = np.array(curve_prim.GetPointsAttr().Get(time))
bsdf, _, _ = material.convert_material(prim)
widths = curve_prim.GetWidthsAttr().Get(time)
if widths is not None:
widths = np.array(widths)
if widths.ndim == 0 or widths.size == 1:
radius = np.full((curve_points.shape[0], 1), widths.item())
radius = np.full((curve_points.shape[0], 1), widths.item() * 0.5)
elif widths.size == curve_points.shape[0]:
radius = widths.reshape(-1, 1)
radius = widths.reshape(-1, 1) * 0.5
else:
# Fallback to mean for other interpolations (e.g., uniform per curve)
radius = np.full((curve_points.shape[0], 1), np.mean(widths))
radius = np.full((curve_points.shape[0], 1), np.mean(widths) * 0.5)
else:
radius = np.full((curve_points.shape[0], 1), 0.01)
curve_points = np.hstack([curve_points, radius])
Expand All @@ -143,6 +143,14 @@ def _convert_curves(

# TODO: Correctly parse this from the USD prim.
curve_type = 'linearcurve'
if (
hasattr(curve_prim, 'GetTypeAttr')
and curve_prim.GetTypeAttr().Get(time) == 'cubic'
and curve_prim.GetBasisAttr().Get(time) == 'bspline'
):
curve_type = 'bsplinecurve'
elif prim.IsA(UsdGeom.NurbsCurves):
curve_type = 'bsplinecurve'
curve_obj = _create_empty_mitsuba_curve(curve_type, bsdf)
degree = 3 if curve_type == 'bsplinecurve' else 1
params = mi.traverse(curve_obj)
Expand Down Expand Up @@ -272,6 +280,6 @@ def convert_to_mitsuba(
UsdLux.BoundableLightBase
):
mi_scene_dict[mi_id] = light.convert_light(prim, time)
elif prim.IsA(UsdGeom.BasisCurves):
elif prim.IsA(UsdGeom.Curves):
mi_scene_dict[mi_id] = _convert_curves(prim, time)
return mi_scene_dict
Loading