Jelajahi Sumber

Project library now returns the external resource path instead of internal one when provided with a resource instance
Fix for GUI list box where setting states would be ignored in a single-select list box

BearishSun 10 tahun lalu
induk
melakukan
874a04a705

+ 1 - 1
BansheeCore/Source/BsTextureImportOptions.cpp

@@ -4,7 +4,7 @@
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
 	TextureImportOptions::TextureImportOptions()
 	TextureImportOptions::TextureImportOptions()
-		:mFormat(PF_B8G8R8A8), mGenerateMips(false), mMaxMip(0), 
+		:mFormat(PF_R8G8B8A8), mGenerateMips(false), mMaxMip(0), 
 		mCPUReadable(false), mSRGB(false)
 		mCPUReadable(false), mSRGB(false)
 	{ }
 	{ }
 
 

+ 1 - 9
BansheeEditor/Include/BsProjectLibrary.h

@@ -134,15 +134,6 @@ namespace BansheeEngine
 		 */
 		 */
 		Vector<LibraryEntry*> search(const WString& pattern, const Vector<UINT32>& typeIds);
 		Vector<LibraryEntry*> search(const WString& pattern, const Vector<UINT32>& typeIds);
 
 
-		/**
-		 * @brief	Finds the resource meta file for a resource with the specified UUID.
-		 *
-		 * @param	uuid	UUID of the resource to look for.
-		 *
-		 * @return	Resource meta data if found, null otherwise.
-		 */
-		ProjectResourceMetaPtr findResourceMeta(const String& uuid) const;
-
 		/**
 		/**
 		 * @brief	Returns resource path based on its UUID.
 		 * @brief	Returns resource path based on its UUID.
 		 *
 		 *
@@ -406,5 +397,6 @@ namespace BansheeEngine
 
 
 		UnorderedMap<Path, Vector<Path>> mDependencies;
 		UnorderedMap<Path, Vector<Path>> mDependencies;
 		UnorderedSet<Path> mReimportQueue;
 		UnorderedSet<Path> mReimportQueue;
+		UnorderedMap<String, Path> mUUIDToPath;
 	};
 	};
 }
 }

+ 17 - 25
BansheeEditor/Source/BsProjectLibrary.cpp

@@ -317,14 +317,18 @@ namespace BansheeEngine
 	{
 	{
 		if(resource->meta != nullptr)
 		if(resource->meta != nullptr)
 		{
 		{
+			String uuid = resource->meta->getUUID();
+
 			Path path;
 			Path path;
-			if(mResourceManifest->uuidToFilePath(resource->meta->getUUID(), path))
+			if (mResourceManifest->uuidToFilePath(uuid, path))
 			{
 			{
 				if(FileSystem::isFile(path))
 				if(FileSystem::isFile(path))
 					FileSystem::remove(path);
 					FileSystem::remove(path);
 
 
-				mResourceManifest->unregisterResource(resource->meta->getUUID());
+				mResourceManifest->unregisterResource(uuid);
 			}
 			}
+
+			mUUIDToPath.erase(uuid);
 		}
 		}
 
 
 		DirectoryEntry* parent = resource->parent;
 		DirectoryEntry* parent = resource->parent;
@@ -387,6 +391,8 @@ namespace BansheeEngine
 				{
 				{
 					ProjectResourceMetaPtr resourceMeta = std::static_pointer_cast<ProjectResourceMeta>(loadedMeta);
 					ProjectResourceMetaPtr resourceMeta = std::static_pointer_cast<ProjectResourceMeta>(loadedMeta);
 					resource->meta = resourceMeta;
 					resource->meta = resourceMeta;
+
+					mUUIDToPath[resourceMeta->getUUID()] = resource->path;
 				}
 				}
 			}
 			}
 		}
 		}
@@ -416,6 +422,8 @@ namespace BansheeEngine
 				resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), typeId, subMeta, curImportOptions);
 				resource->meta = ProjectResourceMeta::create(importedResource.getUUID(), typeId, subMeta, curImportOptions);
 				FileEncoder fs(metaPath);
 				FileEncoder fs(metaPath);
 				fs.encode(resource->meta.get());
 				fs.encode(resource->meta.get());
+
+				mUUIDToPath[resource->meta->getUUID()] = resource->path;
 			}
 			}
 			else
 			else
 			{
 			{
@@ -574,33 +582,14 @@ namespace BansheeEngine
 		return nullptr;
 		return nullptr;
 	}
 	}
 
 
-	ProjectResourceMetaPtr ProjectLibrary::findResourceMeta(const String& uuid) const
-	{
-		if (mResourceManifest == nullptr)
-			return nullptr;
-
-		Path filePath;
-		if (!mResourceManifest->uuidToFilePath(uuid, filePath))
-			return nullptr;
-
-		LibraryEntry* libEntry = findEntry(filePath);
-		if (libEntry == nullptr || libEntry->type != LibraryEntryType::File)
-			return nullptr;
-
-		ResourceEntry* resEntry = static_cast<ResourceEntry*>(libEntry);
-		return resEntry->meta;
-	}
-
 	Path ProjectLibrary::uuidToPath(const String& uuid) const
 	Path ProjectLibrary::uuidToPath(const String& uuid) const
 	{
 	{
-		if (mResourceManifest == nullptr)
-			return Path();
+		auto iterFind = mUUIDToPath.find(uuid);
 
 
-		Path filePath;
-		if (!mResourceManifest->uuidToFilePath(uuid, filePath))
-			return Path();
+		if (iterFind != mUUIDToPath.end())
+			return iterFind->second;
 
 
-		return filePath;
+		return Path::BLANK;
 	}
 	}
 
 
 	void ProjectLibrary::createEntry(const HResource& resource, const Path& path)
 	void ProjectLibrary::createEntry(const HResource& resource, const Path& path)
@@ -1177,6 +1166,9 @@ namespace BansheeEngine
 						}
 						}
 					}
 					}
 
 
+					if (resEntry->meta != nullptr)
+						mUUIDToPath[resEntry->meta->getUUID()] = resEntry->path;
+
 					if (doAddDependencies)
 					if (doAddDependencies)
 						addDependencies(resEntry);
 						addDependencies(resEntry);
 				}
 				}

+ 12 - 7
BansheeEngine/Source/BsGUIListBox.cpp

@@ -89,19 +89,27 @@ namespace BansheeEngine
 
 
 	void GUIListBox::setElementStates(const Vector<bool>& states)
 	void GUIListBox::setElementStates(const Vector<bool>& states)
 	{
 	{
-		if (!mIsMultiselect)
-			return;
-
 		bool wasOpen = mDropDownBox != nullptr;
 		bool wasOpen = mDropDownBox != nullptr;
 
 
 		if (wasOpen)
 		if (wasOpen)
 			closeListBox();
 			closeListBox();
 
 
-		UINT32 min = (UINT32)std::min(mElementStates.size(), states.size());
+		UINT32 numElements = (UINT32)mElementStates.size();
+		UINT32 min = std::min(numElements, (UINT32)states.size());
 
 
 		for (UINT32 i = 0; i < min; i++)
 		for (UINT32 i = 0; i < min; i++)
+		{
 			mElementStates[i] = states[i];
 			mElementStates[i] = states[i];
 
 
+			if (mElementStates[i] && !mIsMultiselect)
+			{
+				for (UINT32 j = i + 1; j < numElements; j++)
+					mElementStates[j] = false;
+
+				break;
+			}
+		}
+
 		updateContents();
 		updateContents();
 
 
 		if (wasOpen)
 		if (wasOpen)
@@ -223,9 +231,6 @@ namespace BansheeEngine
 		}
 		}
 		else
 		else
 		{
 		{
-			for (UINT32 i = 0; i < (UINT32)mElementStates.size(); i++)
-				mElementStates[i] = false;
-
 			setContent(GUIContent(mElements[selectedIdx]));
 			setContent(GUIContent(mElements[selectedIdx]));
 		}
 		}
 	}
 	}

+ 13 - 8
MBansheeEditor/Inspectors/MeshInspector.cs

@@ -77,7 +77,12 @@ namespace BansheeEditor
             }
             }
 
 
             if (output == null)
             if (output == null)
-                output = new MeshImportOptions();
+            {
+                if (importOptions == null)
+                    output = new MeshImportOptions();
+                else
+                    output = importOptions;
+            }
 
 
             return output;
             return output;
         }
         }
@@ -106,43 +111,43 @@ namespace BansheeEditor
 
 
             bool anythingModified = false;
             bool anythingModified = false;
 
 
-            if (importOptions.ImportNormals != newImportOptions.ImportNormals)
+            if (normalsField.Value != newImportOptions.ImportNormals)
             {
             {
                 normalsField.Value = newImportOptions.ImportNormals;
                 normalsField.Value = newImportOptions.ImportNormals;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.ImportTangents != newImportOptions.ImportTangents)
+            if (tangentsField.Value != newImportOptions.ImportTangents)
             {
             {
                 tangentsField.Value = newImportOptions.ImportTangents;
                 tangentsField.Value = newImportOptions.ImportTangents;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.ImportSkin != newImportOptions.ImportSkin)
+            if (skinField.Value != newImportOptions.ImportSkin)
             {
             {
                 skinField.Value = newImportOptions.ImportSkin;
                 skinField.Value = newImportOptions.ImportSkin;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.ImportBlendShapes != newImportOptions.ImportBlendShapes)
+            if (blendShapesField.Value != newImportOptions.ImportBlendShapes)
             {
             {
                 blendShapesField.Value = newImportOptions.ImportBlendShapes;
                 blendShapesField.Value = newImportOptions.ImportBlendShapes;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.ImportAnimation != newImportOptions.ImportAnimation)
+            if (animationField.Value != newImportOptions.ImportAnimation)
             {
             {
                 animationField.Value = newImportOptions.ImportAnimation;
                 animationField.Value = newImportOptions.ImportAnimation;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.Scale != newImportOptions.Scale)
+            if (scaleField.Value != newImportOptions.Scale)
             {
             {
                 scaleField.Value = newImportOptions.Scale;
                 scaleField.Value = newImportOptions.Scale;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.CPUReadable != newImportOptions.CPUReadable)
+            if (cpuReadableField.Value != newImportOptions.CPUReadable)
             {
             {
                 cpuReadableField.Value = newImportOptions.CPUReadable;
                 cpuReadableField.Value = newImportOptions.CPUReadable;
                 anythingModified = true;
                 anythingModified = true;

+ 11 - 6
MBansheeEditor/Inspectors/Texture2DInspector.cs

@@ -71,7 +71,12 @@ namespace BansheeEditor
             }
             }
 
 
             if (output == null)
             if (output == null)
-                output = new TextureImportOptions();
+            {
+                if (importOptions == null)
+                    output = new TextureImportOptions();
+                else
+                    output = importOptions;
+            }
 
 
             return output;
             return output;
         }
         }
@@ -100,31 +105,31 @@ namespace BansheeEditor
 
 
             bool anythingModified = false;
             bool anythingModified = false;
 
 
-            if (importOptions.Format != newImportOptions.Format)
+            if (formatField.Value != (ulong)newImportOptions.Format)
             {
             {
                 formatField.Value = (ulong)newImportOptions.Format;
                 formatField.Value = (ulong)newImportOptions.Format;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.GenerateMipmaps != newImportOptions.GenerateMipmaps)
+            if (generateMipsField.Value != newImportOptions.GenerateMipmaps)
             {
             {
                 generateMipsField.Value = newImportOptions.GenerateMipmaps;
                 generateMipsField.Value = newImportOptions.GenerateMipmaps;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.MaxMipmapLevel != newImportOptions.MaxMipmapLevel)
+            if (maximumMipsField.Value != newImportOptions.MaxMipmapLevel)
             {
             {
                 maximumMipsField.Value = newImportOptions.MaxMipmapLevel;
                 maximumMipsField.Value = newImportOptions.MaxMipmapLevel;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.IsSRGB != newImportOptions.IsSRGB)
+            if (srgbField.Value != newImportOptions.IsSRGB)
             {
             {
                 srgbField.Value = newImportOptions.IsSRGB;
                 srgbField.Value = newImportOptions.IsSRGB;
                 anythingModified = true;
                 anythingModified = true;
             }
             }
 
 
-            if (importOptions.CPUReadable != newImportOptions.CPUReadable)
+            if (cpuReadableField.Value != newImportOptions.CPUReadable)
             {
             {
                 cpuReadableField.Value = newImportOptions.CPUReadable;
                 cpuReadableField.Value = newImportOptions.CPUReadable;
                 anythingModified = true;
                 anythingModified = true;

+ 3 - 0
SBansheeEditor/Source/BsScriptImportOptions.cpp

@@ -37,6 +37,9 @@ namespace BansheeEngine
 		case TID_TextureImportOptions:
 		case TID_TextureImportOptions:
 			return ScriptTextureImportOptions::create(std::static_pointer_cast<TextureImportOptions>(importOptions));
 			return ScriptTextureImportOptions::create(std::static_pointer_cast<TextureImportOptions>(importOptions));
 			break;
 			break;
+		case TID_MeshImportOptions:
+			return ScriptMeshImportOptions::create(std::static_pointer_cast<MeshImportOptions>(importOptions));
+			break;
 		case TID_FontImportOptions:
 		case TID_FontImportOptions:
 			return ScriptFontImportOptions::create(std::static_pointer_cast<FontImportOptions>(importOptions));
 			return ScriptFontImportOptions::create(std::static_pointer_cast<FontImportOptions>(importOptions));
 			break;
 			break;