Procházet zdrojové kódy

Project library no longer reports inactive resource meta-data as if they were active

BearishSun před 9 roky
rodič
revize
a941a6309b

+ 4 - 19
Source/BansheeCore/Include/BsImporter.h

@@ -120,32 +120,17 @@ namespace BansheeEngine
 		 */
 		 */
 
 
 		/**
 		/**
-		 * Adds a new asset importer for the specified file extension. If an asset importer for that extension already 
-		 * exists, it is removed and replaced with the current one.
+		 * Registers a new asset importer for a specific set of extensions (as determined by the implementation). If an
+		 * asset importer for one or multiple extensions already exists, it is removed and replaced with this one.
 		 *
 		 *
-		 *
-		 * @param[in]	importer	The importer that is able to handle files with the specified extension. nullptr if you
-		 * 							want to remove an asset importer for the extension.
+		 * @param[in]	importer	The importer that is able to handle import of certain type of files. 
 		 *
 		 *
 		 * @note	This method should only be called by asset importers themselves on startup. Importer takes ownership
 		 * @note	This method should only be called by asset importers themselves on startup. Importer takes ownership
 		 *			of the provided pointer and will release it. Assumes it is allocated using the general allocator.
 		 *			of the provided pointer and will release it. Assumes it is allocated using the general allocator.
 		 */
 		 */
 		void _registerAssetImporter(SpecificImporter* importer);
 		void _registerAssetImporter(SpecificImporter* importer);
 
 
-		/**
-		 * Imports a resource at the specified location but doesn't create resource handles. This method returns all 
-		 * imported resources, which is relevant for files that can contain multiple resources (for example an FBX which may
-		 * contain both a mesh and animations). 
-		 *
-		 * @param[in]	inputFilePath	Pathname of the input file.
-		 * @param[in]	importOptions	(optional) Options for controlling the import. Caller must ensure import options 
-		 *								actually match the type of the importer used for the file type.
-		 * @return						A list of all imported resources. The primary resource is always the first returned
-		 *								resource. Caller is responsible for creating resource handles for the returned 
-		 *								values.
-		 *
-		 * @see		createImportOptions
-		 */
+		/** Alternative to importAll() which doesn't create resource handles, but instead returns raw resource pointers. */
 		Vector<SubResourceRaw> _importAllRaw(const Path& inputFilePath, SPtr<const ImportOptions> importOptions = nullptr);
 		Vector<SubResourceRaw> _importAllRaw(const Path& inputFilePath, SPtr<const ImportOptions> importOptions = nullptr);
 
 
 		/** @} */
 		/** @} */

+ 24 - 5
Source/BansheeEditor/Include/BsProjectResourceMeta.h

@@ -92,16 +92,34 @@ namespace BansheeEngine
 		 */
 		 */
 		static SPtr<ProjectFileMeta> create(const SPtr<ImportOptions>& importOptions);
 		static SPtr<ProjectFileMeta> create(const SPtr<ImportOptions>& importOptions);
 
 
-		/** Registers a new resource in the file meta-data. */
+		/** 
+		 * Registers a new resource in the file meta-data. 
+		 *
+		 * @param[in]	resourceMeta	Meta-data to register.
+		 * @param[in]	isOld			Set to true if the meta-data doesn't represent a currently active resource, but
+		 *								is instead stored in the case the resource gets restored later.
+		 */
 		void add(const SPtr<ProjectResourceMeta>& resourceMeta);
 		void add(const SPtr<ProjectResourceMeta>& resourceMeta);
 
 
-		/** Removes a resource with the specified UUID from the file meta-data. */
-		void remove(const String& UUID);
+		/** 
+		 * Registers an inactive resource in the file meta-data. Inactive meta-data is stored for resources that used
+		 * to exist, but do not exist currently, in order to restore their handles if they get restored at a later date.
+		 */
+		void addInactive(const SPtr<ProjectResourceMeta>& resourceMeta);
 
 
-		/** Returns meta-data for all resources contained in the file represented by this meta-data object. */
+		/** Returns meta-data for all active resources contained in the file represented by this meta-data object.  */
 		const Vector<SPtr<ProjectResourceMeta>>& getResourceMetaData() const { return mResourceMetaData; }
 		const Vector<SPtr<ProjectResourceMeta>>& getResourceMetaData() const { return mResourceMetaData; }
 
 
-		/** Removes all resource meta-data stored by this object. */
+		/** 
+		 * Returns meta-data for all resources (both active and inactive) contained in the file represented by this
+		 * meta-data object.  
+		 */
+		Vector<SPtr<ProjectResourceMeta>> getAllResourceMetaData() const;
+
+		/** 
+		 * Removes all resource meta-data stored by this object. This includes meta-data for both active and inactive
+		 * resources. 
+		 */
 		void clearResourceMetaData() { mResourceMetaData.clear(); }
 		void clearResourceMetaData() { mResourceMetaData.clear(); }
 
 
 		/**	Returns the import options used for importing the resource this object is referencing. */
 		/**	Returns the import options used for importing the resource this object is referencing. */
@@ -123,6 +141,7 @@ namespace BansheeEngine
 		friend class ProjectLibrary;
 		friend class ProjectLibrary;
 
 
 		Vector<SPtr<ProjectResourceMeta>> mResourceMetaData;
 		Vector<SPtr<ProjectResourceMeta>> mResourceMetaData;
+		Vector<SPtr<ProjectResourceMeta>> mInactiveResourceMetaData;
 		SPtr<ImportOptions> mImportOptions;
 		SPtr<ImportOptions> mImportOptions;
 		bool mIncludeInBuild;
 		bool mIncludeInBuild;
 
 

+ 1 - 0
Source/BansheeEditor/Include/BsProjectResourceMetaRTTI.h

@@ -54,6 +54,7 @@ namespace BansheeEngine
 			BS_RTTI_MEMBER_REFLPTR(mImportOptions, 1)
 			BS_RTTI_MEMBER_REFLPTR(mImportOptions, 1)
 			BS_RTTI_MEMBER_PLAIN(mIncludeInBuild, 4)
 			BS_RTTI_MEMBER_PLAIN(mIncludeInBuild, 4)
 			BS_RTTI_MEMBER_REFLPTR_ARRAY(mResourceMetaData, 5)
 			BS_RTTI_MEMBER_REFLPTR_ARRAY(mResourceMetaData, 5)
+			BS_RTTI_MEMBER_REFLPTR_ARRAY(mInactiveResourceMetaData, 6)
 		BS_END_RTTI_MEMBERS
 		BS_END_RTTI_MEMBERS
 
 
 	public:
 	public:

+ 2 - 2
Source/BansheeEditor/Source/BsProjectLibrary.cpp

@@ -467,7 +467,7 @@ namespace BansheeEngine
 				if (!isNativeResource)
 				if (!isNativeResource)
 				{
 				{
 					Vector<SubResourceRaw> importedResourcesRaw = gImporter()._importAllRaw(fileEntry->path, curImportOptions);
 					Vector<SubResourceRaw> importedResourcesRaw = gImporter()._importAllRaw(fileEntry->path, curImportOptions);
-					Vector<SPtr<ProjectResourceMeta>> existingResourceMetas = fileEntry->meta->getResourceMetaData();
+					Vector<SPtr<ProjectResourceMeta>> existingResourceMetas = fileEntry->meta->getAllResourceMetaData();
 					fileEntry->meta->clearResourceMetaData();
 					fileEntry->meta->clearResourceMetaData();
 
 
 					for(auto& resEntry : importedResourcesRaw)
 					for(auto& resEntry : importedResourcesRaw)
@@ -510,7 +510,7 @@ namespace BansheeEngine
 					if(!pruneResourceMetas)
 					if(!pruneResourceMetas)
 					{
 					{
 						for (auto& entry : existingResourceMetas)
 						for (auto& entry : existingResourceMetas)
-							fileEntry->meta->add(entry);
+							fileEntry->meta->addInactive(entry);
 					}
 					}
 				}
 				}
 
 

+ 11 - 5
Source/BansheeEditor/Source/BsProjectResourceMeta.cpp

@@ -62,13 +62,19 @@ namespace BansheeEngine
 		mResourceMetaData.push_back(resourceMeta);
 		mResourceMetaData.push_back(resourceMeta);
 	}
 	}
 
 
-	void ProjectFileMeta::remove(const String& UUID)
+	void ProjectFileMeta::addInactive(const SPtr<ProjectResourceMeta>& resourceMeta)
 	{
 	{
-		auto iterFind = std::find_if(mResourceMetaData.begin(), mResourceMetaData.end(),
-			[&](auto& x) { return x->getUUID() == UUID; });
+		mInactiveResourceMetaData.push_back(resourceMeta);
+	}
+
+	Vector<SPtr<ProjectResourceMeta>> ProjectFileMeta::getAllResourceMetaData() const
+	{
+		Vector<SPtr<ProjectResourceMeta>> output(mResourceMetaData);
+
+		for (auto& entry : mInactiveResourceMetaData)
+			output.push_back(entry);
 
 
-		if (iterFind != mResourceMetaData.end())
-			mResourceMetaData.erase(iterFind);
+		return output;
 	}
 	}
 
 
 	bool ProjectFileMeta::hasTypeId(UINT32 typeId) const
 	bool ProjectFileMeta::hasTypeId(UINT32 typeId) const