Clamp to float min and max.
This commit is contained in:
parent
0c40c08662
commit
e05b214adc
|
@ -728,24 +728,17 @@ static void ReadNodeHierarchy(
|
||||||
FbxVector4 localTranslation = localTransform.GetT();
|
FbxVector4 localTranslation = localTransform.GetT();
|
||||||
localTranslation.FixIncorrectValue();
|
localTranslation.FixIncorrectValue();
|
||||||
for (int32_t i = 0; i < 3; i++) {
|
for (int32_t i = 0; i < 3; i++) {
|
||||||
if (localTranslation[i] < FBXSDK_FLOAT_MIN ||
|
localTranslation[i] = FbxClamp(float(localTranslation[i]), FBXSDK_FLOAT_MIN, FBXSDK_FLOAT_MAX);
|
||||||
localTranslation[i] > FBXSDK_FLOAT_MAX) {
|
|
||||||
localTranslation[i] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FbxQuaternion localRotation = localTransform.GetQ();
|
FbxQuaternion localRotation = localTransform.GetQ();
|
||||||
for (int32_t i = 0; i < 4; i++) {
|
for (int32_t i = 0; i < 4; i++) {
|
||||||
if (localRotation[i] < FBXSDK_FLOAT_MIN ||
|
localRotation[i] = FbxClamp(float(localRotation[i]), FBXSDK_FLOAT_MIN, FBXSDK_FLOAT_MAX);
|
||||||
localRotation[i] > FBXSDK_FLOAT_MAX) {
|
|
||||||
localRotation[i] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FbxVector4 localScaling = computeLocalScale(pNode);
|
FbxVector4 localScaling = computeLocalScale(pNode);
|
||||||
localScaling.FixIncorrectValue();
|
localScaling.FixIncorrectValue();
|
||||||
for (int32_t i = 0; i < 3; i++) {
|
for (int32_t i = 0; i < 3; i++) {
|
||||||
if (localScaling[i] < FBXSDK_FLOAT_MIN ||
|
localScaling[i] = FbxClamp(float(localScaling[i]), FBXSDK_FLOAT_MIN, FBXSDK_FLOAT_MAX);
|
||||||
localScaling[i] > FBXSDK_FLOAT_MAX ||
|
if (abs(localScaling[i]) < FBXSDK_FLOAT_EPSILON) {
|
||||||
abs(localScaling[i]) < FBXSDK_FLOAT_EPSILON) {
|
|
||||||
localScaling[i] = 1.0;
|
localScaling[i] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,25 +750,21 @@ static void ReadNodeHierarchy(
|
||||||
FbxVector4 nodeGeometricTranslationPivot = pNode->GetGeometricTranslation(FbxNode::eSourcePivot);
|
FbxVector4 nodeGeometricTranslationPivot = pNode->GetGeometricTranslation(FbxNode::eSourcePivot);
|
||||||
nodeGeometricTranslationPivot.FixIncorrectValue();
|
nodeGeometricTranslationPivot.FixIncorrectValue();
|
||||||
for (int32_t i = 0; i < 3; i++) {
|
for (int32_t i = 0; i < 3; i++) {
|
||||||
if (nodeGeometricTranslationPivot[i] < FBXSDK_FLOAT_MIN ||
|
nodeGeometricTranslationPivot[i] =
|
||||||
nodeGeometricTranslationPivot[i] > FBXSDK_FLOAT_MAX) {
|
FbxClamp(float(nodeGeometricTranslationPivot[i]), FBXSDK_FLOAT_MIN, FBXSDK_FLOAT_MAX);
|
||||||
nodeGeometricTranslationPivot[i] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FbxVector4 nodeGeometricRotationPivot = pNode->GetGeometricRotation(FbxNode::eSourcePivot);
|
FbxVector4 nodeGeometricRotationPivot = pNode->GetGeometricRotation(FbxNode::eSourcePivot);
|
||||||
nodeGeometricRotationPivot.FixIncorrectValue();
|
nodeGeometricRotationPivot.FixIncorrectValue();
|
||||||
for (int32_t i = 0; i < 3; i++) {
|
for (int32_t i = 0; i < 3; i++) {
|
||||||
if (nodeGeometricRotationPivot[i] < FBXSDK_FLOAT_MIN ||
|
nodeGeometricRotationPivot[i] =
|
||||||
nodeGeometricRotationPivot[i] > FBXSDK_FLOAT_MAX) {
|
FbxClamp(float(nodeGeometricRotationPivot[i]), FBXSDK_FLOAT_MIN, FBXSDK_FLOAT_MAX);
|
||||||
nodeGeometricRotationPivot[i] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FbxVector4 nodeGeometricScalePivot = pNode->GetGeometricScaling(FbxNode::eSourcePivot);
|
FbxVector4 nodeGeometricScalePivot = pNode->GetGeometricScaling(FbxNode::eSourcePivot);
|
||||||
nodeGeometricScalePivot.FixIncorrectValue();
|
nodeGeometricScalePivot.FixIncorrectValue();
|
||||||
for (int32_t i = 0; i < 3; i++) {
|
for (int32_t i = 0; i < 3; i++) {
|
||||||
if (nodeGeometricScalePivot[i] < FBXSDK_FLOAT_MIN ||
|
nodeGeometricScalePivot[i] =
|
||||||
nodeGeometricScalePivot[i] > FBXSDK_FLOAT_MAX ||
|
FbxClamp(float(nodeGeometricScalePivot[i]), FBXSDK_FLOAT_MIN, FBXSDK_FLOAT_MAX);
|
||||||
abs(nodeGeometricScalePivot[i]) < FBXSDK_FLOAT_EPSILON) {
|
if (abs(nodeGeometricScalePivot[i]) < FBXSDK_FLOAT_EPSILON) {
|
||||||
nodeGeometricScalePivot[i] = 1.0;
|
nodeGeometricScalePivot[i] = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,9 +924,10 @@ static void ReadAnimations(RawModel& raw, FbxScene* pScene, const GltfOptions& o
|
||||||
|
|
||||||
int targetCount = static_cast<int>(blendShapes.GetTargetShapeCount(channelIx));
|
int targetCount = static_cast<int>(blendShapes.GetTargetShapeCount(channelIx));
|
||||||
|
|
||||||
// the target shape 'fullWeight' values are a strictly ascending list of floats (between
|
// the target shape 'fullWeight' values are a strictly ascending list of floats
|
||||||
// 0 and 100), forming a sequence of intervals -- this convenience function figures out
|
// (between 0 and 100), forming a sequence of intervals -- this convenience function
|
||||||
// if 'p' lays between some certain target fullWeights, and if so where (from 0 to 1).
|
// figures out if 'p' lays between some certain target fullWeights, and if so where
|
||||||
|
// (from 0 to 1).
|
||||||
auto findInInterval = [&](const double p, const int n) {
|
auto findInInterval = [&](const double p, const int n) {
|
||||||
if (n >= targetCount) {
|
if (n >= targetCount) {
|
||||||
// p is certainly completely left of this interval
|
// p is certainly completely left of this interval
|
||||||
|
|
Loading…
Reference in New Issue