Explorar el Código

Encoder: Fixes bug in FBX encoder where skinned models would not load if the model appeared before the skeleton node hierarchy.

Also changed Model.cpp to not use wireframe for lines and points.
Darryl Gough hace 14 años
padre
commit
66959418b3

+ 8 - 8
gameplay-encoder/src/FBXSceneEncoder.cpp

@@ -226,7 +226,7 @@ void FBXSceneEncoder::loadScene(KFbxScene* fbxScene)
         const int childCount = rootNode->GetChildCount();
         for (int i = 0; i < childCount; ++i)
         {
-            Node* node = loadNode(rootNode->GetChild(i), NULL);
+            Node* node = loadNode(rootNode->GetChild(i));
             if (node)
             {
                 scene->add(node);
@@ -448,7 +448,7 @@ void FBXSceneEncoder::loadAnimations(KFbxScene* fbxScene, const EncoderArguments
     }
 }
 
-Node* FBXSceneEncoder::loadNode(KFbxNode* fbxNode, Node* parent)
+Node* FBXSceneEncoder::loadNode(KFbxNode* fbxNode)
 {
     Node* node = NULL;
 
@@ -467,10 +467,6 @@ Node* FBXSceneEncoder::loadNode(KFbxNode* fbxNode, Node* parent)
     {
         node->setId(id);
     }
-    if (parent)
-    {
-        parent->addChild(node);
-    }
     _gamePlayFile.addNode(node);
 
     transformNode(fbxNode, node);
@@ -490,7 +486,11 @@ Node* FBXSceneEncoder::loadNode(KFbxNode* fbxNode, Node* parent)
     const int childCount = fbxNode->GetChildCount();
     for (int i = 0; i < childCount; ++i)
     {
-        loadNode(fbxNode->GetChild(i), node);
+        Node* child = loadNode(fbxNode->GetChild(i));
+        if (child)
+        {
+            node->addChild(child);
+        }
     }
     return node;
 }
@@ -710,7 +710,7 @@ void FBXSceneEncoder::loadSkin(KFbxMesh* fbxMesh, Model* model)
                     const char* jointName = linkedNode->GetName();
                     assert(jointName);
                     jointNames.push_back(jointName);
-                    Node* joint = _gamePlayFile.getNode(jointName);
+                    Node* joint = loadNode(linkedNode);
                     assert(joint);
                     joints.push_back(joint);
 

+ 1 - 2
gameplay-encoder/src/FBXSceneEncoder.h

@@ -138,11 +138,10 @@ private:
      * Loads the FBX Node and creates a GamePlay Node.
      * 
      * @param fbxNode The FBX Node to load.
-     * @param parent The parent node that the newly created node should be added to. May be NULL.
      * 
      * @return The newly created Node or NULL if the node could not be loaded.
      */
-    Node* loadNode(KFbxNode* fbxNode, Node* parent);
+    Node* loadNode(KFbxNode* fbxNode);
     
     /**
      * Loads the FbxMesh and returns a GamePlay mesh.

+ 1 - 0
gameplay/src/Model.cpp

@@ -218,6 +218,7 @@ void Model::setNode(Node* node)
 
 void Model::draw(bool wireframe)
 {
+    wireframe &= _mesh->getPrimitiveType() == Mesh::TRIANGLES | _mesh->getPrimitiveType() == Mesh::TRIANGLE_STRIP;
     unsigned int count = _mesh->getPartCount();
     if (count == 0)
     {