Ver Fonte

Merge remote-tracking branch 'official/master' into contrib

Léo Terziman há 11 anos atrás
pai
commit
172c917c37
3 ficheiros alterados com 23 adições e 23 exclusões
  1. 15 18
      code/FBXConverter.cpp
  2. 7 4
      code/PlyParser.cpp
  3. 1 1
      code/PlyParser.h

+ 15 - 18
code/FBXConverter.cpp

@@ -62,7 +62,6 @@ namespace FBX {
 
 
 #define MAGIC_NODE_TAG "_$AssimpFbx$"
-#define MAGIC_NULL_TAG "_$AssimpFbxNull$"
 
 #define CONVERT_FBX_TIME(time) static_cast<double>(time) / 46186158000L
 
@@ -95,7 +94,13 @@ public:
 		TransformationComp_MAXIMUM
 	};
 
+	enum MetadataKeys
+	{
+		MetadataKeys_UserProperties = 0,
+		MetadataKeys_IsNull,
 
+		MetadataKeys_MAXIMUM
+	};
 
 public:
 
@@ -257,14 +262,6 @@ private:
 						ConvertCameras(*model);
 					}
 
-					// preserve the info that a node was marked as Null node
-					// in the original file.
-					if(model->IsNull()) {
-						const std::string& new_name = original_name + MAGIC_NULL_TAG;
-						RenameNode(original_name, new_name);
-						name_carrier->mName.Set( new_name.c_str() );
-					}
-
 					nodes.push_back(nodes_chain.front());	
 					nodes_chain.clear();
 				}
@@ -764,20 +761,20 @@ private:
 	{
 		const PropertyTable& props = model.Props();
 
-		// find user defined properties
-		const std::string& userProps = PropertyGet<std::string>(props, "UDP3DSMAX", "");
-
-		//setup metadata //TODO: make metadata more friendly (eg. have Add()/Remove() functions to be easier to use)
+		//create metadata on node
 		aiMetadata* data = new aiMetadata();
-		data->mNumProperties = 1;
+		data->mNumProperties = MetadataKeys_MAXIMUM;
 		data->mKeys = new aiString[data->mNumProperties]();
 		data->mValues = new aiString[data->mNumProperties]();
+		nd.mMetaData = data;
 
-		//add user properties
-		data->mKeys[0].Set("UserProperties");
-		data->mValues[0].Set(userProps);
+		// find user defined properties
+		data->mKeys[MetadataKeys_UserProperties].Set("UserProperties");
+		data->mValues[MetadataKeys_UserProperties].Set(PropertyGet<std::string>(props, "UDP3DSMAX", ""));
 
-		nd.mMetaData = data;
+		// preserve the info that a node was marked as Null node in the original file.
+		data->mKeys[MetadataKeys_IsNull].Set("IsNull");
+		data->mValues[MetadataKeys_IsNull].Set(model.IsNull() ? "true" : "false");
 	}
 
 	// ------------------------------------------------------------------------------------------------

+ 7 - 4
code/PlyParser.cpp

@@ -427,7 +427,7 @@ bool PLY::DOM::SkipComments (const char* pCur,
 }
 
 // ------------------------------------------------------------------------------------------------
-bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut)
+bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut,bool isBinary)
 {
 	ai_assert(NULL != pCur && NULL != pCurOut);
 	DefaultLogger::get()->debug("PLY::DOM::ParseHeader() begin");
@@ -458,7 +458,10 @@ bool PLY::DOM::ParseHeader (const char* pCur,const char** pCurOut)
 			SkipLine(&pCur);
 		}
 	}
-	SkipSpacesAndLineEnd(pCur,&pCur);
+	if(!isBinary)
+	{ // it would occur an error, if binary data start with values as space or line end.
+		SkipSpacesAndLineEnd(pCur,&pCur);
+	}
 	*pCurOut = pCur;
 
 	DefaultLogger::get()->debug("PLY::DOM::ParseHeader() succeeded");
@@ -527,7 +530,7 @@ bool PLY::DOM::ParseInstanceBinary (const char* pCur,DOM* p_pcOut,bool p_bBE)
 
 	DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() begin");
 
-	if(!p_pcOut->ParseHeader(pCur,&pCur))
+	if(!p_pcOut->ParseHeader(pCur,&pCur,true))
 	{
 		DefaultLogger::get()->debug("PLY::DOM::ParseInstanceBinary() failure");
 		return false;
@@ -550,7 +553,7 @@ bool PLY::DOM::ParseInstance (const char* pCur,DOM* p_pcOut)
 	DefaultLogger::get()->debug("PLY::DOM::ParseInstance() begin");
 
 
-	if(!p_pcOut->ParseHeader(pCur,&pCur))
+	if(!p_pcOut->ParseHeader(pCur,&pCur,false))
 	{
 		DefaultLogger::get()->debug("PLY::DOM::ParseInstance() failure");
 		return false;

+ 1 - 1
code/PlyParser.h

@@ -434,7 +434,7 @@ private:
 
 	// -------------------------------------------------------------------
 	//! Handle the file header and read all element descriptions
-	bool ParseHeader (const char* pCur,const char** pCurOut);
+	bool ParseHeader (const char* pCur,const char** pCurOut, bool p_bBE);
 
 	// -------------------------------------------------------------------
 	//! Read in all element instance lists