Explorar o código

Added an option to import a collision mesh to mesh import

BearishSun %!s(int64=10) %!d(string=hai) anos
pai
achega
e96694c328

+ 15 - 0
BansheeCore/Include/BsMeshImportOptions.h

@@ -11,6 +11,14 @@ namespace BansheeEngine
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
+	/** Controls what type of collision mesh should be imported during mesh import. */
+	enum class CollisionMeshType
+	{
+		None, /**< No collision mesh will be imported. */
+		Normal, /**< Normal triangle mesh will be imported. */
+		Convex /**< A convex hull will be generated from the source mesh. */
+	};
+
 	/**
 	/**
 	 * Contains import options you may use to control how is a mesh imported from some external format into engine format.
 	 * Contains import options you may use to control how is a mesh imported from some external format into engine format.
 	 */
 	 */
@@ -67,6 +75,12 @@ namespace BansheeEngine
 		/**	Retrieves a value that will uniformly scale the imported mesh by the specified value. */
 		/**	Retrieves a value that will uniformly scale the imported mesh by the specified value. */
 		float getImportScale() const { return mImportScale; }
 		float getImportScale() const { return mImportScale; }
 
 
+		/**	Sets a value that controls what type (if any) of collision mesh should be imported. */
+		void setCollisionMeshType(CollisionMeshType type) { mCollisionMeshType = type; }
+
+		/**	Retrieves a value that controls what type (if any) of collision mesh should be imported. */
+		CollisionMeshType getCollisionMeshType() const { return mCollisionMeshType; }
+
 		/************************************************************************/
 		/************************************************************************/
 		/* 								SERIALIZATION                      		*/
 		/* 								SERIALIZATION                      		*/
 		/************************************************************************/
 		/************************************************************************/
@@ -83,6 +97,7 @@ namespace BansheeEngine
 		bool mImportSkin;
 		bool mImportSkin;
 		bool mImportAnimation;
 		bool mImportAnimation;
 		float mImportScale;
 		float mImportScale;
+		CollisionMeshType mCollisionMeshType;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 17 - 28
BansheeCore/Include/BsMeshImportOptionsRTTI.h

@@ -13,40 +13,29 @@ namespace BansheeEngine
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
-	class BS_CORE_EXPORT MeshImportOptionsRTTI : public RTTIType < MeshImportOptions, ImportOptions, MeshImportOptionsRTTI >
+	class BS_CORE_EXPORT MeshImportOptionsRTTI : public RTTIType <MeshImportOptions, ImportOptions, MeshImportOptionsRTTI>
 	{
 	{
 	private:
 	private:
-		bool& getCPUReadable(MeshImportOptions* obj) { return obj->mCPUReadable; }
-		void setCPUReadable(MeshImportOptions* obj, bool& value) { obj->mCPUReadable = value; }
-		
-		bool& getImportNormals(MeshImportOptions* obj) { return obj->mImportNormals; }
-		void setImportNormals(MeshImportOptions* obj, bool& value) { obj->mImportNormals = value; }
-		
-		bool& getImportTangents(MeshImportOptions* obj) { return obj->mImportTangents; }
-		void setImportTangents(MeshImportOptions* obj, bool& value) { obj->mImportTangents = value; }
-		
-		bool& getImportBlendShapes(MeshImportOptions* obj) { return obj->mImportBlendShapes; }
-		void setImportBlendShapes(MeshImportOptions* obj, bool& value) { obj->mImportBlendShapes = value; }
-		
-		bool& getImportSkin(MeshImportOptions* obj) { return obj->mImportSkin; }
-		void setImportSkin(MeshImportOptions* obj, bool& value) { obj->mImportSkin = value; }
-		
-		bool& getImportAnimation(MeshImportOptions* obj) { return obj->mImportAnimation; }
-		void setImportAnimation(MeshImportOptions* obj, bool& value) { obj->mImportAnimation = value; }
-
-		float& getImportScale(MeshImportOptions* obj) { return obj->mImportScale; }
-		void setImportScale(MeshImportOptions* obj, float& value) { obj->mImportScale = value; }
+		BS_PLAIN_MEMBER(mCPUReadable)
+		BS_PLAIN_MEMBER(mImportNormals)
+		BS_PLAIN_MEMBER(mImportTangents)
+		BS_PLAIN_MEMBER(mImportBlendShapes)
+		BS_PLAIN_MEMBER(mImportSkin)
+		BS_PLAIN_MEMBER(mImportAnimation)
+		BS_PLAIN_MEMBER(mImportScale)
+		BS_PLAIN_MEMBER(mCollisionMeshType)
 
 
 	public:
 	public:
 		MeshImportOptionsRTTI()
 		MeshImportOptionsRTTI()
 		{
 		{
-			addPlainField("mCPUReadable", 0, &MeshImportOptionsRTTI::getCPUReadable, &MeshImportOptionsRTTI::setCPUReadable);
-			addPlainField("mImportNormals", 1, &MeshImportOptionsRTTI::getImportNormals, &MeshImportOptionsRTTI::setImportNormals);
-			addPlainField("mImportTangents", 2, &MeshImportOptionsRTTI::getImportTangents, &MeshImportOptionsRTTI::setImportTangents);
-			addPlainField("mImportBlendShapes", 3, &MeshImportOptionsRTTI::getImportBlendShapes, &MeshImportOptionsRTTI::setImportBlendShapes);
-			addPlainField("mImportSkin", 4, &MeshImportOptionsRTTI::getImportSkin, &MeshImportOptionsRTTI::setImportSkin);
-			addPlainField("mImportAnimation", 5, &MeshImportOptionsRTTI::getImportAnimation, &MeshImportOptionsRTTI::setImportAnimation);
-			addPlainField("mImportScale", 6, &MeshImportOptionsRTTI::getImportScale, &MeshImportOptionsRTTI::setImportScale);
+			BS_ADD_PLAIN_FIELD(mCPUReadable, 0);
+			BS_ADD_PLAIN_FIELD(mImportNormals, 1);
+			BS_ADD_PLAIN_FIELD(mImportTangents, 2);
+			BS_ADD_PLAIN_FIELD(mImportBlendShapes, 3);
+			BS_ADD_PLAIN_FIELD(mImportSkin, 4);
+			BS_ADD_PLAIN_FIELD(mImportAnimation, 5);
+			BS_ADD_PLAIN_FIELD(mImportScale, 6);
+			BS_ADD_PLAIN_FIELD(mCollisionMeshType, 7);
 		}
 		}
 
 
 		const String& getRTTIName() override
 		const String& getRTTIName() override

+ 1 - 1
BansheeCore/Source/BsMeshImportOptions.cpp

@@ -8,7 +8,7 @@ namespace BansheeEngine
 	MeshImportOptions::MeshImportOptions()
 	MeshImportOptions::MeshImportOptions()
 		:mCPUReadable(false), mImportNormals(true), mImportTangents(true),
 		:mCPUReadable(false), mImportNormals(true), mImportTangents(true),
 		mImportBlendShapes(false), mImportSkin(false), mImportAnimation(false),
 		mImportBlendShapes(false), mImportSkin(false), mImportAnimation(false),
-		mImportScale(1.0f)
+		mImportScale(1.0f), mCollisionMeshType(CollisionMeshType::None)
 	{ }
 	{ }
 
 
 	/************************************************************************/
 	/************************************************************************/

+ 43 - 68
BansheeFBXImporter/Include/BsFBXImporter.h

@@ -11,137 +11,112 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	/**
-	 * @brief	Importer implementation that handles FBX/OBJ/DAE/3DS file import 
-	 *			by using the FBX SDK.
-	 */
+	/** Importer implementation that handles FBX/OBJ/DAE/3DS file import by using the FBX SDK. */
 	class BS_FBX_EXPORT FBXImporter : public SpecificImporter
 	class BS_FBX_EXPORT FBXImporter : public SpecificImporter
 	{
 	{
 	public:
 	public:
 		FBXImporter();
 		FBXImporter();
 		virtual ~FBXImporter();
 		virtual ~FBXImporter();
 
 
-		/**
-		 * @copydoc	SpecificImporter::isExtensionSupported
-		 */
-		virtual bool isExtensionSupported(const WString& ext) const override;
+		/** @copydoc SpecificImporter::isExtensionSupported */
+		bool isExtensionSupported(const WString& ext) const override;
 
 
-		/**
-		 * @copydoc	SpecificImporter::isMagicNumberSupported
-		 */
-		virtual bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const override;
+		/** @copydoc SpecificImporter::isMagicNumberSupported */
+		bool isMagicNumberSupported(const UINT8* magicNumPtr, UINT32 numBytes) const override;
 
 
-		/**
-		 * @copydoc	SpecificImporter::import
-		 */
-		virtual ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions) override;
+		/** @copydoc SpecificImporter::import */
+		ResourcePtr import(const Path& filePath, ConstImportOptionsPtr importOptions) override;
 
 
-		/**
-		 * @copydoc	SpecificImporter::createImportOptions
-		 */
+		/** @copydoc SpecificImporter::importAll */
+		Vector<SubResourceRaw> importAll(const Path& filePath, ConstImportOptionsPtr importOptions) override;
+
+		/** @copydoc SpecificImporter::createImportOptions */
 		ImportOptionsPtr createImportOptions() const override;
 		ImportOptionsPtr createImportOptions() const override;
 	private:
 	private:
 		/**
 		/**
-		 * @brief	Starts up FBX SDK. Must be called before any other operations.
-		 *			Outputs an FBX manager and FBX scene instances you should use in
-		 *			further operations. Returns false if the SDK wasn't started properly.
+		 * Starts up FBX SDK. Must be called before any other operations. Outputs an FBX manager and FBX scene instances
+		 * you should use in further operations. Returns false if the SDK wasn't started properly.
 		 */
 		 */
 		bool startUpSdk(FbxScene*& scene);
 		bool startUpSdk(FbxScene*& scene);
 
 
-		/**
-		 * @brief	Shuts down FBX SDK. Must be called after any other operations.
-		 */
+		/**	Shuts down FBX SDK. Must be called after any other operations. */
 		void shutDownSdk();
 		void shutDownSdk();
 
 
+		/** 
+		 * Reads the FBX file and outputs mesh data from the read file. Sub-mesh information will be output in @p subMeshes.
+		 */
+		RendererMeshDataPtr importMeshData(const Path& filePath, ConstImportOptionsPtr importOptions, 
+			Vector<SubMesh>& subMeshes);
+
 		/**
 		/**
-		 * @brief	Loads the data from the file at the provided path into the provided FBX scene. 
-		 *			Returns false if the file couldn't be loaded.
+		 * Loads the data from the file at the provided path into the provided FBX scene. Returns false if the file
+		 * couldn't be loaded.
 		 */
 		 */
 		bool loadFBXFile(FbxScene* scene, const Path& filePath);
 		bool loadFBXFile(FbxScene* scene, const Path& filePath);
 
 
 		/**
 		/**
-		 * @brief	Parses an FBX scene. Find all meshes in the scene and returns mesh data object
-		 *			containing all vertices, indexes and other mesh information. Also outputs
-		 *			a sub-mesh array that allows you locate specific sub-meshes within the returned
-		 *			mesh data object. If requested animation and blend shape data is output as well.
+		 * Parses an FBX scene. Find all meshes in the scene and returns mesh data object containing all vertices, indexes
+		 * and other mesh information. Also outputs a sub-mesh array that allows you locate specific sub-meshes within the
+		 * returned mesh data object. If requested animation and blend shape data is output as well.
 		 */
 		 */
 		void parseScene(FbxScene* scene, const FBXImportOptions& options, FBXImportScene& outputScene);
 		void parseScene(FbxScene* scene, const FBXImportOptions& options, FBXImportScene& outputScene);
 
 
 		/**
 		/**
-		 * @brief	Parses an FBX mesh. Converts it from FBX SDK format into a mesh data object containing
-		 *			one or multiple sub-meshes.
+		 * Parses an FBX mesh. Converts it from FBX SDK format into a mesh data object containing one or multiple sub-meshes.
 		 */
 		 */
 		void parseMesh(FbxMesh* mesh, FBXImportNode* parentNode, const FBXImportOptions& options, FBXImportScene& outputScene);
 		void parseMesh(FbxMesh* mesh, FBXImportNode* parentNode, const FBXImportOptions& options, FBXImportScene& outputScene);
 
 
-		/**
-		 * @brief	Imports blend shapes for all the meshes that are part of the scene.
-		 */
+		/**	Imports blend shapes for all the meshes that are part of the scene. */
 		void importBlendShapes(FBXImportScene& scene, const FBXImportOptions& options);
 		void importBlendShapes(FBXImportScene& scene, const FBXImportOptions& options);
 
 
 		/**
 		/**
-		 * @brief	Parses a single FBX blend shape frame. Converts it from FBX SDK format into a 
-		 *			shape data object containing position and tangent frame.
+		 * Parses a single FBX blend shape frame. Converts it from FBX SDK format into a shape data object containing
+		 * position and tangent frame.
 		 */
 		 */
 		void importBlendShapeFrame(FbxShape* shape, const FBXImportMesh& mesh, const FBXImportOptions& options, FBXBlendShapeFrame& outFrame);
 		void importBlendShapeFrame(FbxShape* shape, const FBXImportMesh& mesh, const FBXImportOptions& options, FBXBlendShapeFrame& outFrame);
 
 
-		/**
-		 * @brief	Imports skinning information and bones for all meshes.
-		 */
+		/**	Imports skinning information and bones for all meshes. */
 		void importSkin(FBXImportScene& scene);
 		void importSkin(FBXImportScene& scene);
 
 
-		/**
-		 * @brief	Imports skinning information and bones for the specified mesh.
-		 */
+		/**	Imports skinning information and bones for the specified mesh. */
 		void importSkin(FBXImportScene& scene, FbxSkin* skin, FBXImportMesh& mesh);
 		void importSkin(FBXImportScene& scene, FbxSkin* skin, FBXImportMesh& mesh);
 
 
-		/**
-		 * @brief	Imports all bone and blend shape animations from the FBX.
-		 */
+		/**	Imports all bone and blend shape animations from the FBX. */
 		void importAnimations(FbxScene* scene, FBXImportOptions& importOptions, FBXImportScene& importScene);
 		void importAnimations(FbxScene* scene, FBXImportOptions& importOptions, FBXImportScene& importScene);
 
 
 		/**
 		/**
-		 * @brief	Imports all animations for the specified animation layer and outputs them in the provided clip.
-		 *			Child nodes will be iterated recursively.
+		 * Imports all animations for the specified animation layer and outputs them in the provided clip. Child nodes will
+		 * be iterated recursively.
 		 */
 		 */
 		void importAnimations(FbxAnimLayer* layer, FbxNode* node, FBXImportOptions& importOptions, 
 		void importAnimations(FbxAnimLayer* layer, FbxNode* node, FBXImportOptions& importOptions, 
 			FBXAnimationClip& clip, FBXImportScene& importScene);
 			FBXAnimationClip& clip, FBXImportScene& importScene);
 
 
-		/**
-		 * @brief	Converts a single FBX animation curve into an engine curve format, resampling it if
-		 *			necessary.
-		 */
+		/**	Converts a single FBX animation curve into an engine curve format, resampling it if necessary. */
 		void importCurve(FbxAnimCurve* fbxCurve, FBXImportOptions& importOptions, FBXAnimationCurve& curve, float start, float end);
 		void importCurve(FbxAnimCurve* fbxCurve, FBXImportOptions& importOptions, FBXAnimationCurve& curve, float start, float end);
 
 
-		/**
-		 * @brief	Converts a set of curves containing rotation in euler angles into a set of curves using
-		 *			quaternion rotation.
-		 */
+		/**	Converts a set of curves containing rotation in euler angles into a set of curves using	quaternion rotation. */
 		void eulerToQuaternionCurves(FBXAnimationCurve(&eulerCurves)[3], FBXAnimationCurve(&quatCurves)[4]);
 		void eulerToQuaternionCurves(FBXAnimationCurve(&eulerCurves)[3], FBXAnimationCurve(&quatCurves)[4]);
 
 
 		/**
 		/**
-		 * @brief	Converts all the meshes from per-index attributes to per-vertex attributes.
+		 * Converts all the meshes from per-index attributes to per-vertex attributes.
 		 *
 		 *
-		 * @note	This method will replace all meshes in the scene with new ones, and delete old ones
-		 *			so be sure not to keep any mesh references.
+		 * @note	
+		 * This method will replace all meshes in the scene with new ones, and delete old ones so be sure not to keep any
+		 * mesh references.
 		 */
 		 */
 		void splitMeshVertices(FBXImportScene& scene);
 		void splitMeshVertices(FBXImportScene& scene);
 
 
 		/**
 		/**
-		 * @brief	Traverses over all meshes in the scene and generates normals, tangents and bitangents if they're missing.
+		 * Traverses over all meshes in the scene and generates normals, tangents and bitangents if they're missing.
 		 *
 		 *
 		 * @note	This assumes vertices have already been split and shouldn't be called on pre-split meshes.
 		 * @note	This assumes vertices have already been split and shouldn't be called on pre-split meshes.
 		 */
 		 */
 		void generateMissingTangentSpace(FBXImportScene& scene, const FBXImportOptions& options);
 		void generateMissingTangentSpace(FBXImportScene& scene, const FBXImportOptions& options);
 
 
-		/**
-		 * @brief	Converts the mesh data from the imported FBX scene into mesh data that can be used
-		 *			for initializing a mesh.
-		 */
+		/**Converts the mesh data from the imported FBX scene into mesh data that can be used for initializing a mesh. */
 		RendererMeshDataPtr generateMeshData(const FBXImportScene& scene, const FBXImportOptions& options, Vector<SubMesh>& subMeshes);
 		RendererMeshDataPtr generateMeshData(const FBXImportScene& scene, const FBXImportOptions& options, Vector<SubMesh>& subMeshes);
 
 
-		/**
-		 * @brief	Creates an internal representation of an FBX node from an FbxNode object.
-		 */
+		/**	Creates an internal representation of an FBX node from an FbxNode object. */
 		FBXImportNode* createImportNode(FBXImportScene& scene, FbxNode* fbxNode, FBXImportNode* parent);
 		FBXImportNode* createImportNode(FBXImportScene& scene, FbxNode* fbxNode, FBXImportNode* parent);
 
 
 	private:
 	private:

+ 68 - 12
BansheeFBXImporter/Source/BsFBXImporter.cpp

@@ -16,6 +16,8 @@
 #include "BsMeshUtility.h"
 #include "BsMeshUtility.h"
 #include "BsRendererMeshData.h"
 #include "BsRendererMeshData.h"
 #include "BsMeshImportOptions.h"
 #include "BsMeshImportOptions.h"
+#include "BsPhysicsMesh.h"
+#include "BsPhysics.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -109,6 +111,70 @@ namespace BansheeEngine
 	}
 	}
 
 
 	ResourcePtr FBXImporter::import(const Path& filePath, ConstImportOptionsPtr importOptions)
 	ResourcePtr FBXImporter::import(const Path& filePath, ConstImportOptionsPtr importOptions)
+	{
+		Vector<SubMesh> subMeshes;
+		RendererMeshDataPtr rendererMeshData = importMeshData(filePath, importOptions, subMeshes);
+
+		const MeshImportOptions* meshImportOptions = static_cast<const MeshImportOptions*>(importOptions.get());
+
+		INT32 usage = MU_STATIC;
+		if (meshImportOptions->getCPUReadable())
+			usage |= MU_CPUCACHED;
+
+		MeshPtr mesh = Mesh::_createPtr(rendererMeshData->getData(), subMeshes, usage);
+
+		WString fileName = filePath.getWFilename(false);
+		mesh->setName(fileName);
+
+		return mesh;
+	}
+
+	Vector<SubResourceRaw> FBXImporter::importAll(const Path& filePath, ConstImportOptionsPtr importOptions)
+	{
+		Vector<SubMesh> subMeshes;
+		RendererMeshDataPtr rendererMeshData = importMeshData(filePath, importOptions, subMeshes);
+
+		const MeshImportOptions* meshImportOptions = static_cast<const MeshImportOptions*>(importOptions.get());
+
+		INT32 usage = MU_STATIC;
+		if (meshImportOptions->getCPUReadable())
+			usage |= MU_CPUCACHED;
+
+		MeshPtr mesh = Mesh::_createPtr(rendererMeshData->getData(), subMeshes, usage);
+
+		WString fileName = filePath.getWFilename(false);
+		mesh->setName(fileName);
+
+		Vector<SubResourceRaw> output;
+		if(mesh != nullptr)
+		{
+			output.push_back({ L"primary", mesh });
+
+			CollisionMeshType collisionMeshType = meshImportOptions->getCollisionMeshType();
+			if(collisionMeshType != CollisionMeshType::None)
+			{
+				if(Physics::isStarted())
+				{
+					PhysicsMeshType type = collisionMeshType == CollisionMeshType::Convex ? 
+						PhysicsMeshType::Convex : PhysicsMeshType::Triangle;
+
+					SPtr<PhysicsMesh> physicsMesh = PhysicsMesh::_createPtr(rendererMeshData->getData(), type);
+
+					output.push_back({ L"collision", physicsMesh });
+				}
+				else
+				{
+					LOGWRN("Cannot generate a collision mesh as the physics module was not started.");
+				}
+
+			}
+		}
+
+		return output;
+	}
+
+	RendererMeshDataPtr FBXImporter::importMeshData(const Path& filePath, ConstImportOptionsPtr importOptions, 
+		Vector<SubMesh>& subMeshes)
 	{
 	{
 		FbxScene* fbxScene = nullptr;
 		FbxScene* fbxScene = nullptr;
 
 
@@ -141,24 +207,14 @@ namespace BansheeEngine
 
 
 		splitMeshVertices(importedScene);
 		splitMeshVertices(importedScene);
 		generateMissingTangentSpace(importedScene, fbxImportOptions);
 		generateMissingTangentSpace(importedScene, fbxImportOptions);
-		
-		Vector<SubMesh> subMeshes;
+
 		RendererMeshDataPtr rendererMeshData = generateMeshData(importedScene, fbxImportOptions, subMeshes);
 		RendererMeshDataPtr rendererMeshData = generateMeshData(importedScene, fbxImportOptions, subMeshes);
 
 
 		// TODO - Later: Optimize mesh: Remove bad and degenerate polygons, weld nearby vertices, optimize for vertex cache
 		// TODO - Later: Optimize mesh: Remove bad and degenerate polygons, weld nearby vertices, optimize for vertex cache
 
 
 		shutDownSdk();
 		shutDownSdk();
 
 
-		INT32 usage = MU_STATIC;
-		if (meshImportOptions->getCPUReadable())
-			usage |= MU_CPUCACHED;
-
-		MeshPtr mesh = Mesh::_createPtr(rendererMeshData->getData(), subMeshes, usage);
-
-		WString fileName = filePath.getWFilename(false);
-		mesh->setName(fileName);
-
-		return mesh;
+		return rendererMeshData;
 	}
 	}
 
 
 	bool FBXImporter::startUpSdk(FbxScene*& scene)
 	bool FBXImporter::startUpSdk(FbxScene*& scene)

+ 34 - 0
MBansheeEditor/ImportOptions.cs

@@ -183,6 +183,15 @@ namespace BansheeEditor
             set { Internal_SetScale(mCachedPtr, value); }
             set { Internal_SetScale(mCachedPtr, value); }
         }
         }
 
 
+        /// <summary>
+        /// Controls what type (if any) of collision mesh should be imported.
+        /// </summary>
+        public CollisionMeshType CollisionMeshType
+        {
+            get { return (CollisionMeshType)Internal_GetCollisionMeshType(mCachedPtr); }
+            set { Internal_SetCollisionMeshType(mCachedPtr, (int)value); }
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_CreateInstance(MeshImportOptions instance);
         private static extern void Internal_CreateInstance(MeshImportOptions instance);
 
 
@@ -227,6 +236,31 @@ namespace BansheeEditor
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetScale(IntPtr thisPtr, float value);
         private static extern void Internal_SetScale(IntPtr thisPtr, float value);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern int Internal_GetCollisionMeshType(IntPtr thisPtr);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_SetCollisionMeshType(IntPtr thisPtr, int value);
+    }
+
+    /// <summary>
+    /// Controls what type of collision mesh should be imported during mesh import.
+    /// </summary>
+    public enum CollisionMeshType // Note: Must match C++ enum CollisionMeshImport
+    {
+        /// <summary>
+        /// No collision mesh will be imported.
+        /// </summary>
+        None,
+        /// <summary>
+        /// Normal triangle mesh will be imported.
+        /// </summary>
+        Normal,
+        /// <summary>
+        /// A convex hull will be generated from the source mesh.
+        /// </summary>
+        Convex
     }
     }
 
 
     /// <summary>
     /// <summary>

+ 7 - 0
MBansheeEditor/Inspectors/FontInspector.cs

@@ -96,9 +96,16 @@ namespace BansheeEditor
             charRanges.OnExpand += x => Persistent.SetBool("charRanges_Expanded", x);
             charRanges.OnExpand += x => Persistent.SetBool("charRanges_Expanded", x);
 
 
             renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode"));
             renderModeField = new GUIEnumField(typeof(FontRenderMode), new LocEdString("Render mode"));
+            renderModeField.OnSelectionChanged += x => importOptions.RenderMode = (FontRenderMode)x;
+
             boldField = new GUIToggleField(new LocEdString("Bold"));
             boldField = new GUIToggleField(new LocEdString("Bold"));
+            boldField.OnChanged += x => importOptions.Bold = x;
+
             italicField = new GUIToggleField(new LocEdString("Italic"));
             italicField = new GUIToggleField(new LocEdString("Italic"));
+            italicField.OnChanged += x => importOptions.Italic = x;
+
             dpiField = new GUIIntField(new LocEdString("DPI"));
             dpiField = new GUIIntField(new LocEdString("DPI"));
+            dpiField.OnChanged += x => importOptions.DPI = x;
 
 
             reimportButton = new GUIButton(new LocEdString("Reimport"));
             reimportButton = new GUIButton(new LocEdString("Reimport"));
             reimportButton.OnClick += TriggerReimport;
             reimportButton.OnClick += TriggerReimport;

+ 4 - 0
MBansheeEditor/Inspectors/MeshInspector.cs

@@ -18,6 +18,7 @@ namespace BansheeEditor
         private GUIToggleField animationField = new GUIToggleField(new LocEdString("Import Animation"));
         private GUIToggleField animationField = new GUIToggleField(new LocEdString("Import Animation"));
         private GUIFloatField scaleField = new GUIFloatField(new LocEdString("Scale"));
         private GUIFloatField scaleField = new GUIFloatField(new LocEdString("Scale"));
         private GUIToggleField cpuReadableField = new GUIToggleField(new LocEdString("CPU readable"));
         private GUIToggleField cpuReadableField = new GUIToggleField(new LocEdString("CPU readable"));
+        private GUIEnumField collisionMeshTypeField = new GUIEnumField(typeof(CollisionMeshType), new LocEdString("Collision mesh"));
         private GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));
         private GUIButton reimportButton = new GUIButton(new LocEdString("Reimport"));
 
 
         private MeshImportOptions importOptions;
         private MeshImportOptions importOptions;
@@ -36,6 +37,7 @@ namespace BansheeEditor
                 animationField.OnChanged += x => importOptions.ImportAnimation = x;
                 animationField.OnChanged += x => importOptions.ImportAnimation = x;
                 scaleField.OnChanged += x => importOptions.Scale = x;
                 scaleField.OnChanged += x => importOptions.Scale = x;
                 cpuReadableField.OnChanged += x => importOptions.CPUReadable = x;
                 cpuReadableField.OnChanged += x => importOptions.CPUReadable = x;
+                collisionMeshTypeField.OnSelectionChanged += x => importOptions.CollisionMeshType = (CollisionMeshType)x;
 
 
                 reimportButton.OnClick += TriggerReimport;
                 reimportButton.OnClick += TriggerReimport;
 
 
@@ -46,6 +48,7 @@ namespace BansheeEditor
                 Layout.AddElement(animationField);
                 Layout.AddElement(animationField);
                 Layout.AddElement(scaleField);
                 Layout.AddElement(scaleField);
                 Layout.AddElement(cpuReadableField);
                 Layout.AddElement(cpuReadableField);
+                Layout.AddElement(collisionMeshTypeField);
                 Layout.AddSpace(10);
                 Layout.AddSpace(10);
 
 
                 GUILayout reimportButtonLayout = Layout.AddLayoutX();
                 GUILayout reimportButtonLayout = Layout.AddLayoutX();
@@ -66,6 +69,7 @@ namespace BansheeEditor
             animationField.Value = newImportOptions.ImportAnimation;
             animationField.Value = newImportOptions.ImportAnimation;
             scaleField.Value = newImportOptions.Scale;
             scaleField.Value = newImportOptions.Scale;
             cpuReadableField.Value = newImportOptions.CPUReadable;
             cpuReadableField.Value = newImportOptions.CPUReadable;
+            collisionMeshTypeField.Value = (ulong)newImportOptions.CollisionMeshType;
 
 
             importOptions = newImportOptions;
             importOptions = newImportOptions;
 
 

+ 2 - 0
SBansheeEditor/Include/BsScriptImportOptions.h

@@ -138,6 +138,8 @@ namespace BansheeEngine
 		static void internal_SetImportBlendShapes(ScriptMeshImportOptions* thisPtr, bool value);
 		static void internal_SetImportBlendShapes(ScriptMeshImportOptions* thisPtr, bool value);
 		static float internal_GetScale(ScriptMeshImportOptions* thisPtr);
 		static float internal_GetScale(ScriptMeshImportOptions* thisPtr);
 		static void internal_SetScale(ScriptMeshImportOptions* thisPtr, float value);
 		static void internal_SetScale(ScriptMeshImportOptions* thisPtr, float value);
+		static int internal_GetCollisionMeshType(ScriptMeshImportOptions* thisPtr);
+		static void internal_SetCollisionMeshType(ScriptMeshImportOptions* thisPtr, int value);
 	};
 	};
 
 
 	/**
 	/**

+ 12 - 0
SBansheeEditor/Source/BsScriptImportOptions.cpp

@@ -181,6 +181,8 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_SetImportBlendShapes", &ScriptMeshImportOptions::internal_SetImportBlendShapes);
 		metaData.scriptClass->addInternalCall("Internal_SetImportBlendShapes", &ScriptMeshImportOptions::internal_SetImportBlendShapes);
 		metaData.scriptClass->addInternalCall("Internal_GetScale", &ScriptMeshImportOptions::internal_GetScale);
 		metaData.scriptClass->addInternalCall("Internal_GetScale", &ScriptMeshImportOptions::internal_GetScale);
 		metaData.scriptClass->addInternalCall("Internal_SetScale", &ScriptMeshImportOptions::internal_SetScale);
 		metaData.scriptClass->addInternalCall("Internal_SetScale", &ScriptMeshImportOptions::internal_SetScale);
+		metaData.scriptClass->addInternalCall("Internal_GetCollisionMeshType", &ScriptMeshImportOptions::internal_GetCollisionMeshType);
+		metaData.scriptClass->addInternalCall("Internal_SetCollisionMeshType", &ScriptMeshImportOptions::internal_SetCollisionMeshType);
 	}
 	}
 
 
 	SPtr<MeshImportOptions> ScriptMeshImportOptions::getMeshImportOptions()
 	SPtr<MeshImportOptions> ScriptMeshImportOptions::getMeshImportOptions()
@@ -277,6 +279,16 @@ namespace BansheeEngine
 		thisPtr->getMeshImportOptions()->setImportScale(value);
 		thisPtr->getMeshImportOptions()->setImportScale(value);
 	}
 	}
 
 
+	int ScriptMeshImportOptions::internal_GetCollisionMeshType(ScriptMeshImportOptions* thisPtr)
+	{
+		return (int)thisPtr->getMeshImportOptions()->getCollisionMeshType();
+	}
+
+	void ScriptMeshImportOptions::internal_SetCollisionMeshType(ScriptMeshImportOptions* thisPtr, int value)
+	{
+		thisPtr->getMeshImportOptions()->setCollisionMeshType((CollisionMeshType)value);
+	}
+
 	ScriptFontImportOptions::ScriptFontImportOptions(MonoObject* instance)
 	ScriptFontImportOptions::ScriptFontImportOptions(MonoObject* instance)
 		:ScriptObject(instance)
 		:ScriptObject(instance)
 	{
 	{