Kimkulling/fix double precision tests (#5660)

* Make color single precision

* Fix the unittests for double precision

* Fix merge issues

* Fix issues with Vertex + Color4

* Fix vertex operator, some tests are still red.
This commit is contained in:
Kim Kulling
2024-07-12 14:37:49 +02:00
committed by GitHub
parent 0cb1693689
commit 35e4f1bf64
22 changed files with 291 additions and 145 deletions

View File

@@ -422,7 +422,7 @@ void Parser::ParseLV1SoftSkinBlock() {
me.first = static_cast<int>(curMesh->mBones.size());
curMesh->mBones.emplace_back(bone);
}
ParseLV4MeshFloat(me.second);
ParseLV4MeshReal(me.second);
// Add the new bone weight to list
vert.mBoneWeights.push_back(me);
@@ -580,14 +580,14 @@ void Parser::ParseLV2MaterialBlock(ASE::Material &mat) {
}
// material transparency
if (TokenMatch(mFilePtr, "MATERIAL_TRANSPARENCY", 21)) {
ParseLV4MeshFloat(mat.mTransparency);
ParseLV4MeshReal(mat.mTransparency);
mat.mTransparency = ai_real(1.0) - mat.mTransparency;
continue;
}
// material self illumination
if (TokenMatch(mFilePtr, "MATERIAL_SELFILLUM", 18)) {
ai_real f = 0.0;
ParseLV4MeshFloat(f);
ParseLV4MeshReal(f);
mat.mEmissive.r = f;
mat.mEmissive.g = f;
@@ -596,7 +596,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material &mat) {
}
// material shininess
if (TokenMatch(mFilePtr, "MATERIAL_SHINE", 14)) {
ParseLV4MeshFloat(mat.mSpecularExponent);
ParseLV4MeshReal(mat.mSpecularExponent);
mat.mSpecularExponent *= 15;
continue;
}
@@ -607,7 +607,7 @@ void Parser::ParseLV2MaterialBlock(ASE::Material &mat) {
}
// material shininess strength
if (TokenMatch(mFilePtr, "MATERIAL_SHINESTRENGTH", 22)) {
ParseLV4MeshFloat(mat.mShininessStrength);
ParseLV4MeshReal(mat.mShininessStrength);
continue;
}
// diffuse color map
@@ -731,32 +731,32 @@ void Parser::ParseLV3MapBlock(Texture &map) {
}
// offset on the u axis
if (TokenMatch(mFilePtr, "UVW_U_OFFSET", 12)) {
ParseLV4MeshFloat(map.mOffsetU);
ParseLV4MeshReal(map.mOffsetU);
continue;
}
// offset on the v axis
if (TokenMatch(mFilePtr, "UVW_V_OFFSET", 12)) {
ParseLV4MeshFloat(map.mOffsetV);
ParseLV4MeshReal(map.mOffsetV);
continue;
}
// tiling on the u axis
if (TokenMatch(mFilePtr, "UVW_U_TILING", 12)) {
ParseLV4MeshFloat(map.mScaleU);
ParseLV4MeshReal(map.mScaleU);
continue;
}
// tiling on the v axis
if (TokenMatch(mFilePtr, "UVW_V_TILING", 12)) {
ParseLV4MeshFloat(map.mScaleV);
ParseLV4MeshReal(map.mScaleV);
continue;
}
// rotation around the z-axis
if (TokenMatch(mFilePtr, "UVW_ANGLE", 9)) {
ParseLV4MeshFloat(map.mRotation);
ParseLV4MeshReal(map.mRotation);
continue;
}
// map blending factor
if (TokenMatch(mFilePtr, "MAP_AMOUNT", 10)) {
ParseLV4MeshFloat(map.mTextureBlend);
ParseLV4MeshReal(map.mTextureBlend);
continue;
}
}
@@ -895,15 +895,15 @@ void Parser::ParseLV2CameraSettingsBlock(ASE::Camera &camera) {
if ('*' == *mFilePtr) {
++mFilePtr;
if (TokenMatch(mFilePtr, "CAMERA_NEAR", 11)) {
ParseLV4MeshFloat(camera.mNear);
ParseLV4MeshReal(camera.mNear);
continue;
}
if (TokenMatch(mFilePtr, "CAMERA_FAR", 10)) {
ParseLV4MeshFloat(camera.mFar);
ParseLV4MeshReal(camera.mFar);
continue;
}
if (TokenMatch(mFilePtr, "CAMERA_FOV", 10)) {
ParseLV4MeshFloat(camera.mFOV);
ParseLV4MeshReal(camera.mFOV);
continue;
}
}
@@ -922,15 +922,15 @@ void Parser::ParseLV2LightSettingsBlock(ASE::Light &light) {
continue;
}
if (TokenMatch(mFilePtr, "LIGHT_INTENS", 12)) {
ParseLV4MeshFloat(light.mIntensity);
ParseLV4MeshReal(light.mIntensity);
continue;
}
if (TokenMatch(mFilePtr, "LIGHT_HOTSPOT", 13)) {
ParseLV4MeshFloat(light.mAngle);
ParseLV4MeshReal(light.mAngle);
continue;
}
if (TokenMatch(mFilePtr, "LIGHT_FALLOFF", 13)) {
ParseLV4MeshFloat(light.mFalloff);
ParseLV4MeshReal(light.mFalloff);
continue;
}
}
@@ -1038,7 +1038,7 @@ void Parser::ParseLV3ScaleAnimationBlock(ASE::Animation &anim) {
if (b) {
anim.akeyScaling.emplace_back();
aiVectorKey &key = anim.akeyScaling.back();
ParseLV4MeshFloatTriple(&key.mValue.x, iIndex);
ParseLV4MeshRealTriple(&key.mValue.x, iIndex);
key.mTime = (double)iIndex;
}
}
@@ -1077,7 +1077,7 @@ void Parser::ParseLV3PosAnimationBlock(ASE::Animation &anim) {
if (b) {
anim.akeyPositions.emplace_back();
aiVectorKey &key = anim.akeyPositions.back();
ParseLV4MeshFloatTriple(&key.mValue.x, iIndex);
ParseLV4MeshRealTriple(&key.mValue.x, iIndex);
key.mTime = (double)iIndex;
}
}
@@ -1118,8 +1118,8 @@ void Parser::ParseLV3RotAnimationBlock(ASE::Animation &anim) {
aiQuatKey &key = anim.akeyRotations.back();
aiVector3D v;
ai_real f;
ParseLV4MeshFloatTriple(&v.x, iIndex);
ParseLV4MeshFloat(f);
ParseLV4MeshRealTriple(&v.x, iIndex);
ParseLV4MeshReal(f);
key.mTime = (double)iIndex;
key.mValue = aiQuaternion(v, f);
}
@@ -1163,23 +1163,23 @@ void Parser::ParseLV2NodeTransformBlock(ASE::BaseNode &mesh) {
// fourth row of the transformation matrix - and also the
// only information here that is interesting for targets
if (TokenMatch(mFilePtr, "TM_ROW3", 7)) {
ParseLV4MeshFloatTriple((mode == 1 ? mesh.mTransform[3] : &mesh.mTargetPosition.x));
ParseLV4MeshRealTriple((mode == 1 ? mesh.mTransform[3] : &mesh.mTargetPosition.x));
continue;
}
if (mode == 1) {
// first row of the transformation matrix
if (TokenMatch(mFilePtr, "TM_ROW0", 7)) {
ParseLV4MeshFloatTriple(mesh.mTransform[0]);
ParseLV4MeshRealTriple(mesh.mTransform[0]);
continue;
}
// second row of the transformation matrix
if (TokenMatch(mFilePtr, "TM_ROW1", 7)) {
ParseLV4MeshFloatTriple(mesh.mTransform[1]);
ParseLV4MeshRealTriple(mesh.mTransform[1]);
continue;
}
// third row of the transformation matrix
if (TokenMatch(mFilePtr, "TM_ROW2", 7)) {
ParseLV4MeshFloatTriple(mesh.mTransform[2]);
ParseLV4MeshRealTriple(mesh.mTransform[2]);
continue;
}
// inherited position axes
@@ -1414,7 +1414,7 @@ void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices, ASE::Mesh &mes
// --- ignored
ai_real afVert[3];
ParseLV4MeshFloatTriple(afVert);
ParseLV4MeshRealTriple(afVert);
std::pair<int, float> pairOut;
while (true) {
@@ -1453,7 +1453,7 @@ void Parser::ParseLV3MeshVertexListBlock(
aiVector3D vTemp;
unsigned int iIndex;
ParseLV4MeshFloatTriple(&vTemp.x, iIndex);
ParseLV4MeshRealTriple(&vTemp.x, iIndex);
if (iIndex >= iNumVertices) {
LogWarning("Invalid vertex index. It will be ignored");
@@ -1506,7 +1506,7 @@ void Parser::ParseLV3MeshTListBlock(unsigned int iNumVertices,
if (TokenMatch(mFilePtr, "MESH_TVERT", 10)) {
aiVector3D vTemp;
unsigned int iIndex;
ParseLV4MeshFloatTriple(&vTemp.x, iIndex);
ParseLV4MeshRealTriple(&vTemp.x, iIndex);
if (iIndex >= iNumVertices) {
LogWarning("Tvertex has an invalid index. It will be ignored");
@@ -1657,7 +1657,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh &sMesh) {
++mFilePtr;
if (faceIdx != UINT_MAX && TokenMatch(mFilePtr, "MESH_VERTEXNORMAL", 17)) {
aiVector3D vNormal;
ParseLV4MeshFloatTriple(&vNormal.x, index);
ParseLV4MeshRealTriple(&vNormal.x, index);
if (faceIdx >= sMesh.mFaces.size())
continue;
@@ -1679,7 +1679,7 @@ void Parser::ParseLV3MeshNormalListBlock(ASE::Mesh &sMesh) {
}
if (TokenMatch(mFilePtr, "MESH_FACENORMAL", 15)) {
aiVector3D vNormal;
ParseLV4MeshFloatTriple(&vNormal.x, faceIdx);
ParseLV4MeshRealTriple(&vNormal.x, faceIdx);
if (faceIdx >= sMesh.mFaces.size()) {
ASSIMP_LOG_ERROR("ASE: Invalid vertex index in MESH_FACENORMAL section");
@@ -1844,7 +1844,17 @@ void Parser::ParseLV4MeshLongTriple(unsigned int *apOut, unsigned int &rIndexOut
ParseLV4MeshLongTriple(apOut);
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) {
void Parser::ParseLV4MeshRealTriple(ai_real *apOut, unsigned int &rIndexOut) {
ai_assert(nullptr != apOut);
// parse the index
ParseLV4MeshLong(rIndexOut);
// parse the three others
ParseLV4MeshRealTriple(apOut);
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut) {
ai_assert(nullptr != apOut);
// parse the index
@@ -1854,7 +1864,15 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut, unsigned int &rIndexOut) {
ParseLV4MeshFloatTriple(apOut);
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) {
void Parser::ParseLV4MeshRealTriple(ai_real *apOut) {
ai_assert(nullptr != apOut);
for (unsigned int i = 0; i < 3; ++i) {
ParseLV4MeshReal(apOut[i]);
}
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloatTriple(float* apOut) {
ai_assert(nullptr != apOut);
for (unsigned int i = 0; i < 3; ++i) {
@@ -1862,7 +1880,7 @@ void Parser::ParseLV4MeshFloatTriple(ai_real *apOut) {
}
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloat(ai_real &fOut) {
void Parser::ParseLV4MeshReal(ai_real &fOut) {
// skip spaces and tabs
if (!SkipSpaces(&mFilePtr, mEnd)) {
// LOG
@@ -1875,6 +1893,19 @@ void Parser::ParseLV4MeshFloat(ai_real &fOut) {
mFilePtr = fast_atoreal_move<ai_real>(mFilePtr, fOut);
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshFloat(float &fOut) {
// skip spaces and tabs
if (!SkipSpaces(&mFilePtr, mEnd)) {
// LOG
LogWarning("Unable to parse float: unexpected EOL [#1]");
fOut = 0.0;
++iLineNumber;
return;
}
// parse the first float
mFilePtr = fast_atoreal_move<float>(mFilePtr, fOut);
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshLong(unsigned int &iOut) {
// Skip spaces and tabs
if (!SkipSpaces(&mFilePtr, mEnd)) {