Fit control bones in pose canvas
Add scale factor to make all the bones fit in the canvas of pose editormaster
parent
1543c1a6c7
commit
01b164cdae
|
@ -166,6 +166,8 @@ void AnimalPoser::resolveChainRotation(const std::vector<QString> &limbBoneNames
|
|||
const float &c = targetBeginBoneLength;
|
||||
double cosC = (a*a + b*b - c*c) / (2.0*a*b);
|
||||
angleBetweenDistanceAndMiddleBones = qRadiansToDegrees(acos(cosC));
|
||||
if (std::isnan(angleBetweenDistanceAndMiddleBones) || std::isinf(angleBetweenDistanceAndMiddleBones))
|
||||
angleBetweenDistanceAndMiddleBones = 0;
|
||||
}
|
||||
|
||||
QVector3D targetMiddleBoneStartPosition;
|
||||
|
|
|
@ -406,12 +406,7 @@ bool AnimalRigger::rig()
|
|||
tailPosition = findExtremPointFrom(spineBoneVertices, spineNode.position);
|
||||
}
|
||||
|
||||
QVector3D spineBoneHeadPosition = averagePosition(spineBoneVertices);
|
||||
if (isMainBodyVerticalAligned) {
|
||||
spineBoneHeadPosition.setY(spineNode.coord);
|
||||
} else {
|
||||
spineBoneHeadPosition.setZ(spineNode.coord);
|
||||
}
|
||||
QVector3D spineBoneHeadPosition = spineNode.position;
|
||||
|
||||
QString spineName = namingSpine(spineGenerateOrder);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
const float PoseDocument::m_nodeRadius = 0.01;
|
||||
const float PoseDocument::m_groundPlaneHalfThickness = 0.01 / 4;
|
||||
const bool PoseDocument::m_hideRootAndVirtual = true;
|
||||
const float PoseDocument::m_outcomeScaleFactor = 0.5;
|
||||
|
||||
bool PoseDocument::hasPastableNodesInClipboard() const
|
||||
{
|
||||
|
@ -198,9 +199,9 @@ void PoseDocument::updateRigBones(const std::vector<RiggerBone> *rigBones, const
|
|||
node.partId = m_bonesPartId;
|
||||
node.id = QUuid::createUuid();
|
||||
node.setRadius(m_nodeRadius);
|
||||
node.x = bone.headPosition.x() + 0.5;
|
||||
node.y = -bone.headPosition.y() + 0.5;
|
||||
node.z = -bone.headPosition.z() + 1;
|
||||
node.x = fromOutcomeX(bone.headPosition.x());
|
||||
node.y = fromOutcomeY(bone.headPosition.y());
|
||||
node.z = fromOutcomeZ(bone.headPosition.z());
|
||||
nodeMap[node.id] = node;
|
||||
newAddedNodeIds.insert(node.id);
|
||||
boneIndexToHeadNodeIdMap[edgePair.first] = node.id;
|
||||
|
@ -217,9 +218,9 @@ void PoseDocument::updateRigBones(const std::vector<RiggerBone> *rigBones, const
|
|||
node.partId = m_bonesPartId;
|
||||
node.id = QUuid::createUuid();
|
||||
node.setRadius(m_nodeRadius);
|
||||
node.x = bone.headPosition.x() + 0.5;
|
||||
node.y = -bone.headPosition.y() + 0.5;
|
||||
node.z = -bone.headPosition.z() + 1;
|
||||
node.x = fromOutcomeX(bone.headPosition.x());
|
||||
node.y = fromOutcomeY(bone.headPosition.y());
|
||||
node.z = fromOutcomeZ(bone.headPosition.z());
|
||||
nodeMap[node.id] = node;
|
||||
newAddedNodeIds.insert(node.id);
|
||||
boneIndexToHeadNodeIdMap[edgePair.second] = node.id;
|
||||
|
@ -423,31 +424,31 @@ void PoseDocument::toParameters(std::map<QString, std::map<QString, QString>> &p
|
|||
|
||||
float PoseDocument::fromOutcomeX(float x)
|
||||
{
|
||||
return x + 0.5;
|
||||
return x * m_outcomeScaleFactor + 0.5;
|
||||
}
|
||||
|
||||
float PoseDocument::toOutcomeX(float x)
|
||||
{
|
||||
return x - 0.5;
|
||||
return (x - 0.5) / m_outcomeScaleFactor;
|
||||
}
|
||||
|
||||
float PoseDocument::fromOutcomeY(float y)
|
||||
{
|
||||
return -y + 0.5;
|
||||
return -y * m_outcomeScaleFactor + 0.5;
|
||||
}
|
||||
|
||||
float PoseDocument::toOutcomeY(float y)
|
||||
{
|
||||
return 0.5 - y;
|
||||
return (0.5 - y) / m_outcomeScaleFactor;
|
||||
}
|
||||
|
||||
float PoseDocument::fromOutcomeZ(float z)
|
||||
{
|
||||
return -z + 1;
|
||||
return -z * m_outcomeScaleFactor + 1;
|
||||
}
|
||||
|
||||
float PoseDocument::toOutcomeZ(float z)
|
||||
{
|
||||
return 1.0 - z;
|
||||
return (1.0 - z) / m_outcomeScaleFactor;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
static const float m_nodeRadius;
|
||||
static const float m_groundPlaneHalfThickness;
|
||||
static const bool m_hideRootAndVirtual;
|
||||
static const float m_outcomeScaleFactor;
|
||||
|
||||
private:
|
||||
std::map<QString, std::pair<QUuid, QUuid>> m_boneNameToIdsMap;
|
||||
|
|
Loading…
Reference in New Issue