Merge branch 'master' into PLYcomments#4866
commit
6dc12f57a2
|
@ -269,7 +269,7 @@ aiMesh *MMDImporter::CreateMesh(const pmx::PmxModel *pModel,
|
||||||
dynamic_cast<pmx::PmxVertexSkinningSDEF *>(v->skinning.get());
|
dynamic_cast<pmx::PmxVertexSkinningSDEF *>(v->skinning.get());
|
||||||
switch (v->skinning_type) {
|
switch (v->skinning_type) {
|
||||||
case pmx::PmxVertexSkinningType::BDEF1:
|
case pmx::PmxVertexSkinningType::BDEF1:
|
||||||
bone_vertex_map[vsBDEF1_ptr->bone_index].emplace_back(index, 1.0);
|
bone_vertex_map[vsBDEF1_ptr->bone_index].emplace_back(index, static_cast<ai_real>(1));
|
||||||
break;
|
break;
|
||||||
case pmx::PmxVertexSkinningType::BDEF2:
|
case pmx::PmxVertexSkinningType::BDEF2:
|
||||||
bone_vertex_map[vsBDEF2_ptr->bone_index1].emplace_back(index, vsBDEF2_ptr->bone_weight);
|
bone_vertex_map[vsBDEF2_ptr->bone_index1].emplace_back(index, vsBDEF2_ptr->bone_weight);
|
||||||
|
|
|
@ -193,7 +193,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::list<aiColor3D> &pColors,
|
||||||
|
|
||||||
// create RGBA array from RGB.
|
// create RGBA array from RGB.
|
||||||
for (std::list<aiColor3D>::const_iterator it = pColors.begin(); it != pColors.end(); ++it)
|
for (std::list<aiColor3D>::const_iterator it = pColors.begin(); it != pColors.end(); ++it)
|
||||||
tcol.emplace_back((*it).r, (*it).g, (*it).b, 1);
|
tcol.emplace_back((*it).r, (*it).g, (*it).b, static_cast<ai_real>(1));
|
||||||
|
|
||||||
// call existing function for adding RGBA colors
|
// call existing function for adding RGBA colors
|
||||||
add_color(pMesh, tcol, pColorPerVertex);
|
add_color(pMesh, tcol, pColorPerVertex);
|
||||||
|
@ -238,7 +238,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::vector<int32_t> &pCoordId
|
||||||
|
|
||||||
// create RGBA array from RGB.
|
// create RGBA array from RGB.
|
||||||
for (std::list<aiColor3D>::const_iterator it = pColors.begin(); it != pColors.end(); ++it) {
|
for (std::list<aiColor3D>::const_iterator it = pColors.begin(); it != pColors.end(); ++it) {
|
||||||
tcol.emplace_back((*it).r, (*it).g, (*it).b, 1);
|
tcol.emplace_back((*it).r, (*it).g, (*it).b, static_cast<ai_real>(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// call existing function for adding RGBA colors
|
// call existing function for adding RGBA colors
|
||||||
|
@ -440,7 +440,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::vector<int32_t> &pCoo
|
||||||
// copy list to array because we are need indexed access to normals.
|
// copy list to array because we are need indexed access to normals.
|
||||||
texcoord_arr_copy.reserve(pTexCoords.size());
|
texcoord_arr_copy.reserve(pTexCoords.size());
|
||||||
for (std::list<aiVector2D>::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) {
|
for (std::list<aiVector2D>::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) {
|
||||||
texcoord_arr_copy.emplace_back((*it).x, (*it).y, 0);
|
texcoord_arr_copy.emplace_back((*it).x, (*it).y, static_cast<ai_real>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTexCoordIdx.size() > 0) {
|
if (pTexCoordIdx.size() > 0) {
|
||||||
|
@ -480,7 +480,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::list<aiVector2D> &pTe
|
||||||
// copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus.
|
// copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus.
|
||||||
tc_arr_copy.reserve(pTexCoords.size());
|
tc_arr_copy.reserve(pTexCoords.size());
|
||||||
for (std::list<aiVector2D>::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) {
|
for (std::list<aiVector2D>::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) {
|
||||||
tc_arr_copy.emplace_back((*it).x, (*it).y, 0);
|
tc_arr_copy.emplace_back((*it).x, (*it).y, static_cast<ai_real>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy texture coordinates to mesh
|
// copy texture coordinates to mesh
|
||||||
|
|
|
@ -151,7 +151,7 @@ void X3DImporter::readArcClose2D(XmlNode &node) {
|
||||||
std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
|
std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
|
||||||
|
|
||||||
if ((closureType == "PIE") || (closureType == "\"PIE\""))
|
if ((closureType == "PIE") || (closureType == "\"PIE\""))
|
||||||
vlist.emplace_back(0, 0, 0); // center point - first radial line
|
vlist.emplace_back(static_cast<ai_real>(0), static_cast<ai_real>(0), static_cast<ai_real>(0)); // center point - first radial line
|
||||||
else if ((closureType != "CHORD") && (closureType != "\"CHORD\""))
|
else if ((closureType != "CHORD") && (closureType != "\"CHORD\""))
|
||||||
Throw_IncorrectAttrValue("ArcClose2D", "closureType");
|
Throw_IncorrectAttrValue("ArcClose2D", "closureType");
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ void X3DImporter::readPolyline2D(XmlNode &node) {
|
||||||
|
|
||||||
// convert vec2 to vec3
|
// convert vec2 to vec3
|
||||||
for (std::list<aiVector2D>::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2)
|
for (std::list<aiVector2D>::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2)
|
||||||
tlist.emplace_back(it2->x, it2->y, 0);
|
tlist.emplace_back(it2->x, it2->y, static_cast<ai_real>(0));
|
||||||
|
|
||||||
// convert point set to line set
|
// convert point set to line set
|
||||||
X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices);
|
X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices);
|
||||||
|
@ -361,7 +361,7 @@ void X3DImporter::readPolypoint2D(XmlNode &node) {
|
||||||
|
|
||||||
// convert vec2 to vec3
|
// convert vec2 to vec3
|
||||||
for (std::list<aiVector2D>::iterator it2 = point.begin(); it2 != point.end(); ++it2) {
|
for (std::list<aiVector2D>::iterator it2 = point.begin(); it2 != point.end(); ++it2) {
|
||||||
((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0);
|
((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, static_cast<ai_real>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
((X3DNodeElementGeometry2D *)ne)->NumIndices = 1;
|
((X3DNodeElementGeometry2D *)ne)->NumIndices = 1;
|
||||||
|
@ -405,10 +405,10 @@ void X3DImporter::readRectangle2D(XmlNode &node) {
|
||||||
float y2 = size.y / 2.0f;
|
float y2 = size.y / 2.0f;
|
||||||
std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
|
std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
|
||||||
|
|
||||||
vlist.emplace_back(x2, y1, 0); // 1st point
|
vlist.emplace_back(x2, y1, static_cast<ai_real>(0)); // 1st point
|
||||||
vlist.emplace_back(x2, y2, 0); // 2nd point
|
vlist.emplace_back(x2, y2, static_cast<ai_real>(0)); // 2nd point
|
||||||
vlist.emplace_back(x1, y2, 0); // 3rd point
|
vlist.emplace_back(x1, y2, static_cast<ai_real>(0)); // 3rd point
|
||||||
vlist.emplace_back(x1, y1, 0); // 4th point
|
vlist.emplace_back(x1, y1, static_cast<ai_real>(0)); // 4th point
|
||||||
((X3DNodeElementGeometry2D *)ne)->Solid = solid;
|
((X3DNodeElementGeometry2D *)ne)->Solid = solid;
|
||||||
((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
|
((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
|
||||||
// check for X3DMetadataObject childs.
|
// check for X3DMetadataObject childs.
|
||||||
|
@ -449,7 +449,7 @@ void X3DImporter::readTriangleSet2D(XmlNode &node) {
|
||||||
|
|
||||||
// convert vec2 to vec3
|
// convert vec2 to vec3
|
||||||
for (std::list<aiVector2D>::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) {
|
for (std::list<aiVector2D>::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) {
|
||||||
((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0);
|
((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, static_cast<ai_real>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
((X3DNodeElementGeometry2D *)ne)->Solid = solid;
|
((X3DNodeElementGeometry2D *)ne)->Solid = solid;
|
||||||
|
|
|
@ -67,6 +67,7 @@ GenFaceNormalsProcess::~GenFaceNormalsProcess() = default;
|
||||||
bool GenFaceNormalsProcess::IsActive(unsigned int pFlags) const {
|
bool GenFaceNormalsProcess::IsActive(unsigned int pFlags) const {
|
||||||
force_ = (pFlags & aiProcess_ForceGenNormals) != 0;
|
force_ = (pFlags & aiProcess_ForceGenNormals) != 0;
|
||||||
flippedWindingOrder_ = (pFlags & aiProcess_FlipWindingOrder) != 0;
|
flippedWindingOrder_ = (pFlags & aiProcess_FlipWindingOrder) != 0;
|
||||||
|
leftHanded_ = (pFlags & aiProcess_MakeLeftHanded) != 0;
|
||||||
return (pFlags & aiProcess_GenNormals) != 0;
|
return (pFlags & aiProcess_GenNormals) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,8 +132,10 @@ bool GenFaceNormalsProcess::GenMeshFaceNormals(aiMesh *pMesh) {
|
||||||
const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]];
|
const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]];
|
||||||
const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]];
|
const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]];
|
||||||
const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]];
|
const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]];
|
||||||
if (flippedWindingOrder_)
|
// Boolean XOR - if either but not both of these flags is set, then the winding order has
|
||||||
std::swap( pV2, pV3 );
|
// changed and the cross product to calculate the normal needs to be reversed
|
||||||
|
if (flippedWindingOrder_ != leftHanded_)
|
||||||
|
std::swap(pV2, pV3);
|
||||||
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe();
|
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
bool GenMeshFaceNormals(aiMesh* pcMesh);
|
bool GenMeshFaceNormals(aiMesh* pcMesh);
|
||||||
mutable bool force_ = false;
|
mutable bool force_ = false;
|
||||||
mutable bool flippedWindingOrder_ = false;
|
mutable bool flippedWindingOrder_ = false;
|
||||||
|
mutable bool leftHanded_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
|
@ -69,6 +69,7 @@ GenVertexNormalsProcess::~GenVertexNormalsProcess() = default;
|
||||||
bool GenVertexNormalsProcess::IsActive(unsigned int pFlags) const {
|
bool GenVertexNormalsProcess::IsActive(unsigned int pFlags) const {
|
||||||
force_ = (pFlags & aiProcess_ForceGenNormals) != 0;
|
force_ = (pFlags & aiProcess_ForceGenNormals) != 0;
|
||||||
flippedWindingOrder_ = (pFlags & aiProcess_FlipWindingOrder) != 0;
|
flippedWindingOrder_ = (pFlags & aiProcess_FlipWindingOrder) != 0;
|
||||||
|
leftHanded_ = (pFlags & aiProcess_MakeLeftHanded) != 0;
|
||||||
return (pFlags & aiProcess_GenSmoothNormals) != 0;
|
return (pFlags & aiProcess_GenSmoothNormals) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +142,10 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals(aiMesh *pMesh, unsigned int m
|
||||||
const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]];
|
const aiVector3D *pV1 = &pMesh->mVertices[face.mIndices[0]];
|
||||||
const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]];
|
const aiVector3D *pV2 = &pMesh->mVertices[face.mIndices[1]];
|
||||||
const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]];
|
const aiVector3D *pV3 = &pMesh->mVertices[face.mIndices[face.mNumIndices - 1]];
|
||||||
if (flippedWindingOrder_)
|
// Boolean XOR - if either but not both of these flags is set, then the winding order has
|
||||||
std::swap( pV2, pV3 );
|
// changed and the cross product to calculate the normal needs to be reversed
|
||||||
|
if (flippedWindingOrder_ != leftHanded_)
|
||||||
|
std::swap(pV2, pV3);
|
||||||
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe();
|
const aiVector3D vNor = ((*pV2 - *pV1) ^ (*pV3 - *pV1)).NormalizeSafe();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
for (unsigned int i = 0; i < face.mNumIndices; ++i) {
|
||||||
|
|
|
@ -105,6 +105,7 @@ private:
|
||||||
ai_real configMaxAngle;
|
ai_real configMaxAngle;
|
||||||
mutable bool force_ = false;
|
mutable bool force_ = false;
|
||||||
mutable bool flippedWindingOrder_ = false;
|
mutable bool flippedWindingOrder_ = false;
|
||||||
|
mutable bool leftHanded_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
Loading…
Reference in New Issue