Fix #122513: Add CD_PROP_QUATERNION in copy_primvar_to_blender_attribute

Missed the CD_PROP_QUATERNION case.

Also discovered that both USD and Blender's Quaternions are ordered as
W, x, y, z (instead of W last).

Pull Request: https://projects.blender.org/blender/blender/pulls/122529
This commit is contained in:
Jesse Yurkovich
2024-05-31 19:24:21 +02:00
committed by Jesse Yurkovich
parent 7806d3229a
commit 9182d449d1
2 changed files with 10 additions and 1 deletions

View File

@@ -123,6 +123,10 @@ void copy_primvar_to_blender_attribute(const pxr::UsdGeomPrimvar &primvar,
copy_primvar_to_blender_buffer<bool>(
primvar, timecode, face_indices, attribute.span.typed<bool>());
break;
case CD_PROP_QUATERNION:
copy_primvar_to_blender_buffer<pxr::GfQuatf>(
primvar, timecode, face_indices, attribute.span.typed<math::Quaternion>());
break;
default:
BLI_assert_unreachable();

View File

@@ -64,7 +64,7 @@ template<> inline pxr::GfVec3f convert_value(const ColorGeometry4f value)
}
template<> inline pxr::GfQuatf convert_value(const math::Quaternion value)
{
return pxr::GfQuatf(value.x, value.y, value.z, value.w);
return pxr::GfQuatf(value.w, value.x, value.y, value.z);
}
template<> inline float2 convert_value(const pxr::GfVec2f value)
@@ -79,6 +79,11 @@ template<> inline ColorGeometry4f convert_value(const pxr::GfVec3f value)
{
return ColorGeometry4f(value[0], value[1], value[2], 1.0f);
}
template<> inline math::Quaternion convert_value(const pxr::GfQuatf value)
{
const pxr::GfVec3f &img = value.GetImaginary();
return math::Quaternion(value.GetReal(), img[0], img[1], img[2]);
}
} // namespace detail