Odd Negative Scale: PretransformVertices

PretransformVertices postprocessing now reverses face order when transform is mirroring.
Fixes flip to backfacing in models that mirrored some nodes.

(Odd count of negative scale components, negative determinant)
pull/2818/head
RichardTea 2019-12-09 11:07:13 +00:00
parent 193b02cdac
commit 9cabeddf4f
2 changed files with 570 additions and 610 deletions

File diff suppressed because it is too large Load Diff

View File

@ -59,7 +59,7 @@ struct aiNode;
class PretransformVerticesTest; class PretransformVerticesTest;
namespace Assimp { namespace Assimp {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** The PretransformVertices pre-transforms all vertices in the node tree /** The PretransformVertices pre-transforms all vertices in the node tree
@ -68,97 +68,97 @@ namespace Assimp {
*/ */
class ASSIMP_API PretransformVertices : public BaseProcess { class ASSIMP_API PretransformVertices : public BaseProcess {
public: public:
PretransformVertices (); PretransformVertices();
~PretransformVertices (); ~PretransformVertices();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Check whether step is active // Check whether step is active
bool IsActive( unsigned int pFlags) const; bool IsActive(unsigned int pFlags) const override;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Execute step on a given scene // Execute step on a given scene
void Execute( aiScene* pScene); void Execute(aiScene *pScene) override;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Setup import settings // Setup import settings
void SetupProperties(const Importer* pImp); void SetupProperties(const Importer *pImp) override;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Toggle the 'keep hierarchy' option /** @brief Toggle the 'keep hierarchy' option
* @param keep true for keep configuration. * @param keep true for keep configuration.
*/ */
void KeepHierarchy(bool keep) { void KeepHierarchy(bool keep) {
configKeepHierarchy = keep; configKeepHierarchy = keep;
} }
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** @brief Check whether 'keep hierarchy' is currently enabled. /** @brief Check whether 'keep hierarchy' is currently enabled.
* @return ... * @return ...
*/ */
bool IsHierarchyKept() const { bool IsHierarchyKept() const {
return configKeepHierarchy; return configKeepHierarchy;
} }
private: private:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Count the number of nodes // Count the number of nodes
unsigned int CountNodes( aiNode* pcNode ); unsigned int CountNodes(const aiNode *pcNode) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Get a bitwise combination identifying the vertex format of a mesh // Get a bitwise combination identifying the vertex format of a mesh
unsigned int GetMeshVFormat(aiMesh* pcMesh); unsigned int GetMeshVFormat(aiMesh *pcMesh) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Count the number of vertices in the whole scene and a given // Count the number of vertices in the whole scene and a given
// material index // material index
void CountVerticesAndFaces( aiScene* pcScene, aiNode* pcNode, void CountVerticesAndFaces(const aiScene *pcScene, const aiNode *pcNode,
unsigned int iMat, unsigned int iMat,
unsigned int iVFormat, unsigned int iVFormat,
unsigned int* piFaces, unsigned int *piFaces,
unsigned int* piVertices); unsigned int *piVertices) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Collect vertex/face data // Collect vertex/face data
void CollectData( aiScene* pcScene, aiNode* pcNode, void CollectData(const aiScene *pcScene, const aiNode *pcNode,
unsigned int iMat, unsigned int iMat,
unsigned int iVFormat, unsigned int iVFormat,
aiMesh* pcMeshOut, aiMesh *pcMeshOut,
unsigned int aiCurrent[2], unsigned int aiCurrent[2],
unsigned int* num_refs); unsigned int *num_refs) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Get a list of all vertex formats that occur for a given material // Get a list of all vertex formats that occur for a given material
// The output list contains duplicate elements // The output list contains duplicate elements
void GetVFormatList( aiScene* pcScene, unsigned int iMat, void GetVFormatList(const aiScene *pcScene, unsigned int iMat,
std::list<unsigned int>& aiOut); std::list<unsigned int> &aiOut) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Compute the absolute transformation matrices of each node // Compute the absolute transformation matrices of each node
void ComputeAbsoluteTransform( aiNode* pcNode ); void ComputeAbsoluteTransform(aiNode *pcNode);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Simple routine to build meshes in worldspace, no further optimization // Simple routine to build meshes in worldspace, no further optimization
void BuildWCSMeshes(std::vector<aiMesh*>& out, aiMesh** in, void BuildWCSMeshes(std::vector<aiMesh *> &out, aiMesh **in,
unsigned int numIn, aiNode* node); unsigned int numIn, aiNode *node) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Apply the node transformation to a mesh // Apply the node transformation to a mesh
void ApplyTransform(aiMesh* mesh, const aiMatrix4x4& mat); void ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Reset transformation matrices to identity // Reset transformation matrices to identity
void MakeIdentityTransform(aiNode* nd); void MakeIdentityTransform(aiNode *nd) const;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
// Build reference counters for all meshes // Build reference counters for all meshes
void BuildMeshRefCountArray(aiNode* nd, unsigned int * refs); void BuildMeshRefCountArray(const aiNode *nd, unsigned int *refs) const;
//! Configuration option: keep scene hierarchy as long as possible //! Configuration option: keep scene hierarchy as long as possible
bool configKeepHierarchy; bool configKeepHierarchy;
bool configNormalize; bool configNormalize;
bool configTransform; bool configTransform;
aiMatrix4x4 configTransformation; aiMatrix4x4 configTransformation;
bool mConfigPointCloud; bool mConfigPointCloud;
}; };
} // end of namespace Assimp } // end of namespace Assimp