Skip to content

Commit

Permalink
Assorted minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
0mdc committed Apr 18, 2023
1 parent 54eb24c commit c13ea2d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 17 deletions.
18 changes: 5 additions & 13 deletions src/esp/assets/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1896,8 +1896,7 @@ scene::SceneNode* ResourceManager::createRenderAssetInstanceGeneralPrimitive(
const auto& skinData = skins_[loadedAssetData.meshMetaData.skinIndex.first];
instanceSkinData = std::make_shared<gfx::InstanceSkinData>(skinData);
mapSkinnedModelToArticulatedObject(loadedAssetData.meshMetaData.root,
creation, newNode.scaling(),
instanceSkinData);
creation, instanceSkinData);
ESP_CHECK(instanceSkinData->rootJointId != ID_UNDEFINED,
"Could not map skinned model to articulated object.");
}
Expand Down Expand Up @@ -2911,10 +2910,7 @@ void ResourceManager::addComponent(
void ResourceManager::mapSkinnedModelToArticulatedObject(
const MeshTransformNode& meshTransformNode,
const RenderAssetInstanceCreationInfo& creationInfo,
Mn::Vector3 cumulativeScale,
const std::shared_ptr<gfx::InstanceSkinData>& skinData) {
cumulativeScale /= meshTransformNode.transformFromLocalToParent.scaling();

// Find skin joint ID that matches the node
const auto& gfxBoneName = meshTransformNode.name;
const auto& boneNameJointIdMap = skinData->skinData->boneNameJointIdMap;
Expand All @@ -2930,18 +2926,15 @@ void ResourceManager::mapSkinnedModelToArticulatedObject(

// Map the articulated object link associated with the skin joint
if (linkId != linkIds.end()) {
auto articulatedObjectNode =
auto* articulatedObjectNode =
&creationInfo.rig->getLink(*linkId.base()).node();
skinData->jointIdToArticulatedObjectNode[jointId] = articulatedObjectNode;

// Articulated object nodes aren't scaled.
// Create a child node that carries the scale component.
// This node will be used for rendering.
auto& scaledNode = articulatedObjectNode->createChild();
scaledNode.setScaling(cumulativeScale);
auto& transformNode = articulatedObjectNode->createChild();

// Mapping
skinData->jointIdToTransformNode[jointId] = &scaledNode;
skinData->jointIdToTransformNode[jointId] = &transformNode;
skinData->localTransforms[jointId] =
meshTransformNode.transformFromLocalToParent;

Expand All @@ -2953,8 +2946,7 @@ void ResourceManager::mapSkinnedModelToArticulatedObject(
}

for (const auto& child : meshTransformNode.children) {
mapSkinnedModelToArticulatedObject(child, creationInfo, cumulativeScale,
skinData);
mapSkinnedModelToArticulatedObject(child, creationInfo, skinData);
}
} // mapSkinnedModelToArticulatedObject

Expand Down
2 changes: 0 additions & 2 deletions src/esp/assets/ResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -850,14 +850,12 @@ class ResourceManager {
* @param meshTransformNode The @ref MeshTransformNode being traversed.
* @param creationInfo Creation information for the instance which contains
* the rig.
* @param cumulativeScale TODO
* @param skinData Structure holding the skin and rig configuration for the
* instance
*/
void mapSkinnedModelToArticulatedObject(
const MeshTransformNode& meshTransformNode,
const RenderAssetInstanceCreationInfo& creationInfo,
Mn::Vector3 cumulativeScale,
const std::shared_ptr<gfx::InstanceSkinData>& skinData);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/esp/gfx/SkinData.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct InstanceSkinData {

std::unordered_map<int, Magnum::Matrix4> localTransforms;

InstanceSkinData(const std::shared_ptr<SkinData>& skinData)
explicit InstanceSkinData(const std::shared_ptr<SkinData>& skinData)
: skinData(skinData){};
};
} // namespace gfx
Expand Down
2 changes: 1 addition & 1 deletion src/esp/io/URDFParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class Model {
* @brief Set the path to the render asset to attach to this URDF model.
*/
void setRenderAsset(Cr::Containers::Optional<std::string> renderAsset) {
m_renderAsset = renderAsset;
m_renderAsset = std::move(renderAsset);
}

/**
Expand Down

0 comments on commit c13ea2d

Please sign in to comment.