USD: Skeleton and blend shape import #110912
@ -1144,8 +1144,10 @@ std::optional<XformResult> USDMeshReader::get_local_usd_xform(const float time)
|
||||
if (skel_api.GetGeomBindTransformAttr().HasAuthoredValue()) {
|
||||
pxr::GfMatrix4d bind_xf;
|
||||
if (skel_api.GetGeomBindTransformAttr().Get(&bind_xf)) {
|
||||
/* Assume that if a bind transform is defined, then the
|
||||
* transform is constant. */
|
||||
/* The USD bind transform is a matrix of doubles,
|
||||
* but we cast it to GfMatrix4f because Blender expects
|
||||
* a matrix of floats. Also, we assume the transform
|
||||
* is constant over time. */
|
||||
return XformResult(pxr::GfMatrix4f(bind_xf), true);
|
||||
}
|
||||
else {
|
||||
|
@ -110,7 +110,7 @@ class USDMeshReader : public USDGeomReader {
|
||||
* Override transform computation to account for the binding
|
||||
* transformation for skinned meshes.
|
||||
*/
|
||||
std::optional<XformResult> get_local_usd_xform(const float time) const override;
|
||||
std::optional<XformResult> get_local_usd_xform(float time) const override;
|
||||
makowalski marked this conversation as resolved
Outdated
|
||||
};
|
||||
|
||||
} // namespace blender::io::usd
|
||||
|
@ -350,25 +350,28 @@ void USDStageReader::process_armature_modifiers() const
|
||||
if (!reader->object()) {
|
||||
continue;
|
||||
}
|
||||
if (const USDMeshReader *mesh_reader = dynamic_cast<const USDMeshReader *>(reader)) {
|
||||
/* Check if the mesh object has an armature modifier. */
|
||||
ModifierData *md = BKE_modifiers_findby_type(reader->object(), eModifierType_Armature);
|
||||
if (!md) {
|
||||
continue;
|
||||
}
|
||||
ArmatureModifierData *amd = reinterpret_cast<ArmatureModifierData *>(md);
|
||||
|
||||
/* Assign the armature based on the bound USD skeleton path of the skinned mesh. */
|
||||
std::string skel_path = mesh_reader->get_skeleton_path();
|
||||
std::map<std::string, Object *>::const_iterator it = usd_path_to_armature.find(skel_path);
|
||||
if (it == usd_path_to_armature.end()) {
|
||||
WM_reportf(RPT_WARNING,
|
||||
"%s: Couldn't find armature object corresponding to USD skeleton %s",
|
||||
__func__,
|
||||
skel_path.c_str());
|
||||
}
|
||||
amd->object = it->second;
|
||||
const USDMeshReader *mesh_reader = dynamic_cast<const USDMeshReader *>(reader);
|
||||
makowalski marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
Swap the condition and Swap the condition and `continue` here as well. That wayall the precondition checks use the same logic, and the main path of the for-body can be followed vertically.
|
||||
if (!mesh_reader) {
|
||||
continue;
|
||||
}
|
||||
/* Check if the mesh object has an armature modifier. */
|
||||
ModifierData *md = BKE_modifiers_findby_type(reader->object(), eModifierType_Armature);
|
||||
if (!md) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ArmatureModifierData *amd = reinterpret_cast<ArmatureModifierData *>(md);
|
||||
|
||||
/* Assign the armature based on the bound USD skeleton path of the skinned mesh. */
|
||||
std::string skel_path = mesh_reader->get_skeleton_path();
|
||||
std::map<std::string, Object *>::const_iterator it = usd_path_to_armature.find(skel_path);
|
||||
if (it == usd_path_to_armature.end()) {
|
||||
WM_reportf(RPT_WARNING,
|
||||
"%s: Couldn't find armature object corresponding to USD skeleton %s",
|
||||
__func__,
|
||||
skel_path.c_str());
|
||||
}
|
||||
amd->object = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
/** A transformation matrix and a boolean indicating
|
||||
makowalski marked this conversation as resolved
Outdated
Sybren A. Stüvel
commented
Document what the boolean means. Document what the boolean means.
|
||||
* whether the matrix is constant over time. */
|
||||
using XformResult = std::tuple<pxr::GfMatrix4f, bool>;
|
||||
|
||||
class USDXformReader : public USDPrimReader {
|
||||
@ -63,7 +65,7 @@ class USDXformReader : public USDPrimReader {
|
||||
* - A boolean flag indicating whether the matrix
|
||||
* is constant over time.
|
||||
*/
|
||||
virtual std::optional<XformResult> get_local_usd_xform(const float time) const;
|
||||
virtual std::optional<XformResult> get_local_usd_xform(float time) const;
|
||||
};
|
||||
|
||||
} // namespace blender::io::usd
|
||||
|
Loading…
Reference in New Issue
Block a user
Remove the
const
fromconst float time
, in the declaration it has no meaning. See the C/C++ style guide for more info.