ソースを参照

Removed unused Physics code

BearishSun 9 年 前
コミット
f92ea8ea21

+ 0 - 8
Source/BansheeCore/Include/BsCRigidbody.h

@@ -121,13 +121,6 @@ namespace BansheeEngine
 		/** @copydoc Rigidbody::getVelocitySolverCount */
 		UINT32 getVelocitySolverCount() const { return mVelocitySolverCount; }
 
-		/** @copydoc Rigidbody::setInterpolationMode */
-		void setInterpolationMode(Rigidbody::InterpolationMode value);
-
-		/** @copydoc Rigidbody::getInterpolationMode */
-		Rigidbody::InterpolationMode getInterpolationMode(Rigidbody::InterpolationMode value) const 
-			{ return mInterpolationMode; }
-
 		/** Sets a value that determines which (if any) collision events are reported. */
 		inline void setCollisionReportMode(CollisionReportMode mode);
 
@@ -245,7 +238,6 @@ namespace BansheeEngine
 		UINT32 mPositionSolverCount = 4;
 		UINT32 mVelocitySolverCount = 1;
 		Rigidbody::Flag mFlags = (Rigidbody::Flag)((UINT32)Rigidbody::Flag::AutoTensors | (UINT32)Rigidbody::Flag::AutoMass);
-		Rigidbody::InterpolationMode mInterpolationMode = Rigidbody::InterpolationMode::None;
 		CollisionReportMode mCollisionReportMode = CollisionReportMode::None;
 		Vector3 mCMassPosition;
 		Quaternion mCMassRotation;

+ 0 - 2
Source/BansheeCore/Include/BsCRigidbodyRTTI.h

@@ -30,7 +30,6 @@ namespace BansheeEngine
 		BS_PLAIN_MEMBER(mSleepThreshold);
 		BS_PLAIN_MEMBER(mUseGravity);
 		BS_PLAIN_MEMBER(mIsKinematic);
-		BS_PLAIN_MEMBER(mInterpolationMode);
 		BS_PLAIN_MEMBER(mCollisionReportMode);
 
 	public:
@@ -49,7 +48,6 @@ namespace BansheeEngine
 			BS_ADD_PLAIN_FIELD(mSleepThreshold, 10);
 			BS_ADD_PLAIN_FIELD(mUseGravity, 11);
 			BS_ADD_PLAIN_FIELD(mIsKinematic, 12);
-			BS_ADD_PLAIN_FIELD(mInterpolationMode, 13);
 			BS_ADD_PLAIN_FIELD(mCollisionReportMode, 14);
 		}
 

+ 0 - 21
Source/BansheeCore/Include/BsPhysics.h

@@ -550,32 +550,11 @@ namespace BansheeEngine
 	protected:
 		friend class Rigidbody;
 
-		/** 
-		 * Registers a new rigidbody. Should be called whenever a new rigidbody is created. 
-		 * 
-		 * @param[in]	body		Newly created rigidbody.
-		 * @param[in]	priority	Priority that determines in what order is the physics simulation update applied to
-		 *							rigidbodes. Higher priority means it is applied before lower priority.
-		 */
-		void registerRigidbody(Rigidbody* body, UINT32 priority);
-
-		/** 
-		 * Unregisters a rigidbody. Should be called before a rigidbody is destroyed.
-		 *
-		 * @param[in]	id			ID of the rigidbody to remove.
-		 * @param[in]	priority	Original priority of the rigidbody.
-		 */
-		void unregisterRigidbody(UINT32 id, UINT32 priority);
-
-		/** Changes the priority of a rigidbody. */
-		void updatePriority(UINT32 id, UINT32 oldPriority, UINT32 newPriority);
-
 		mutable Mutex mMutex;
 		bool mCollisionMap[CollisionMapSize][CollisionMapSize];
 
 		bool mUpdateInProgress = false;
 		PhysicsFlags mFlags;
-		Vector<Vector<Rigidbody*>> mRigidbodies; // TODO: Unused for now, but keeping it here just in case I change the design. Remove later.
 
 		const static UINT32 MAX_PRIORITY = 128;
 	};

+ 0 - 32
Source/BansheeCore/Include/BsRigidbody.h

@@ -54,30 +54,6 @@ namespace BansheeEngine
 			CCD = 0x04
 		};
 
-		/** Determines interpolation mode for a rigidbody transform during physics simulation. */
-		enum class InterpolationMode
-		{
-			/** 
-			 * No interpolation is performed, physics transform is copied straight to the rigidbody when physics tick is 
-			 * done. 
-			 */
-			None, 
-			/** 
-			 * Physics transfrom from the most recent tick is saved and slowly interpolated to during the following render 
-			 * frames. This can improve smoothness of the visible movement at framerates higher than the physics simulation 
-			 * but will introduce a delay of one physics tick to all such objects. This can create slight inconsistencies as
-			 * non-interpolated objects will have no such delay, as well as cause input lag due to the delayed reaction.
-			 */
-			Interpolate, 
-			/** 
-			 * Physics transform movement will be extrapolated from the last physics simulation tick. This will improve
-			 * smoothness of visible movement at framerates higher than the physics simulation. Unlike Interpolate it will
-			 * not introduce an input delay, but will introduce an error as the exact position/rotation of the objects is
-			 * extrapolated from the last frame's movement and velocities. 
-			 */
-			Extrapolate
-		};
-
 		/** 
 		 * Constructs a new rigidbody. 
 		 *
@@ -237,12 +213,6 @@ namespace BansheeEngine
 		/** Gets the number of iterations to use when solving for velocity. */
 		virtual UINT32 getVelocitySolverCount() const = 0;
 
-		/** Sets interpolation mode that controls how is the rigidbody transfrom updated from the physics simulation. */
-		virtual void setInterpolationMode(InterpolationMode value) { mInterpolationMode = value; }
-
-		/** Gets interpolation mode that controls how is the rigidbody transfrom updated from the physics simulation. */
-		virtual InterpolationMode getInterpolationMode() const { return mInterpolationMode; }
-
 		/** Sets flags that control the behaviour of the rigidbody. */
 		virtual void setFlags(Flag flags) { mFlags = flags; }
 
@@ -357,9 +327,7 @@ namespace BansheeEngine
 		friend class FCollider;
 
 		Flag mFlags = Flag::None;
-		InterpolationMode mInterpolationMode = InterpolationMode::None;
 		PhysicsObjectOwner mOwner;
-		UINT32 mPriority = 0;
 		UINT32 mPhysicsId = 0;
 		HSceneObject mLinkedSO;
 	};

+ 0 - 9
Source/BansheeCore/Source/BsCRigidbody.cpp

@@ -207,14 +207,6 @@ namespace BansheeEngine
 			mInternal->setVelocitySolverCount(count);
 	}
 
-	void CRigidbody::setInterpolationMode(Rigidbody::InterpolationMode value)
-	{
-		mInterpolationMode = value;
-
-		if (mInternal != nullptr)
-			mInternal->setInterpolationMode(value);
-	}
-
 	void CRigidbody::setCollisionReportMode(CollisionReportMode mode)
 	{
 		if (mCollisionReportMode == mode)
@@ -455,7 +447,6 @@ namespace BansheeEngine
 		mInternal->setSleepThreshold(mSleepThreshold);
 		mInternal->setUseGravity(mUseGravity);
 		mInternal->setIsKinematic(mIsKinematic);
-		mInternal->setInterpolationMode(mInterpolationMode);
 		mInternal->setFlags(mFlags);
 
 		if(((UINT32)mFlags & (UINT32)Rigidbody::Flag::AutoTensors) == 0)

+ 0 - 45
Source/BansheeCore/Source/BsPhysics.cpp

@@ -92,51 +92,6 @@ namespace BansheeEngine
 		return rawToComponent(_convexOverlap(mesh, position, rotation, layer));
 	}
 
-	void Physics::registerRigidbody(Rigidbody* body, UINT32 priority)
-	{
-		assert(priority <= MAX_PRIORITY && "Priority value too high");
-
-		if (mRigidbodies.size() <= priority)
-			mRigidbodies.resize(priority + 1);
-
-		UINT32 nextId = (UINT32)mRigidbodies[priority].size();
-		mRigidbodies[priority].push_back(body);
-		body->_setPhysicsId(nextId);
-	}
-
-	void Physics::unregisterRigidbody(UINT32 id, UINT32 priority)
-	{
-		assert(mRigidbodies.size() >= priority);
-
-		auto& rigidbodies = mRigidbodies[priority];
-		assert(rigidbodies.size() > 0);
-
-		UINT32 lastId = (UINT32)(rigidbodies.size() - 1);
-		if (id != lastId)
-		{
-			rigidbodies[id] = rigidbodies[lastId];
-			rigidbodies[id]->_setPhysicsId(id);
-		}
-
-		rigidbodies.erase(rigidbodies.begin() + lastId);
-	}
-
-	void Physics::updatePriority(UINT32 id, UINT32 oldPriority, UINT32 newPriority)
-	{
-		assert(newPriority <= MAX_PRIORITY && "Priority value too high");
-
-		if (oldPriority == newPriority)
-			return;
-
-		assert(mRigidbodies.size() >= oldPriority);
-
-		auto& rigidbodies = mRigidbodies[oldPriority];
-		Rigidbody* rigidbody = rigidbodies[id];
-
-		unregisterRigidbody(id, oldPriority);
-		registerRigidbody(rigidbody, newPriority);
-	}
-
 	Physics& gPhysics()
 	{
 		return Physics::instance();

+ 1 - 11
Source/BansheeCore/Source/BsRigidbody.cpp

@@ -2,29 +2,19 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsRigidbody.h"
 #include "BsPhysics.h"
-#include "BsFCollider.h"
 #include "BsSceneObject.h"
-#include "BsUtility.h"
 
 namespace BansheeEngine
 {
 	Rigidbody::Rigidbody(const HSceneObject& linkedSO)
 		:mLinkedSO(linkedSO)
 	{
-		mPriority = Utility::getSceneObjectDepth(linkedSO);
-		gPhysics().registerRigidbody(this, mPriority);
-	}
 
-	Rigidbody::~Rigidbody()
-	{
-		gPhysics().unregisterRigidbody(mPhysicsId, mPriority);
 	}
 
-	void Rigidbody::_setPriority(UINT32 priority)
+	Rigidbody::~Rigidbody()
 	{
-		gPhysics().updatePriority(mPhysicsId, mPriority, priority);
 
-		mPriority = priority;
 	}
 
 	void Rigidbody::_setTransform(const Vector3& position, const Quaternion& rotation)

+ 0 - 12
Source/MBansheeEditor/Inspectors/RigidbodyInspector.cs

@@ -20,8 +20,6 @@ namespace BansheeEditor
         private GUIFloatField massField = new GUIFloatField(new LocEdString("Mass"));
         private GUIFloatField linearDragField = new GUIFloatField(new LocEdString("Linear drag"));
         private GUIFloatField angularDragField = new GUIFloatField(new LocEdString("Angular drag"));
-        private GUIEnumField interpolationModeField = new GUIEnumField(typeof (RigidbodyInterpolationMode),
-            new LocEdString("Interpolation mode"));
         private GUIEnumField reportModeField = new GUIEnumField(typeof (CollisionReportMode),
             new LocEdString("Collision report mode"));
         private GUIToggleField ccdField = new GUIToggleField(new LocEdString("Continous"));
@@ -47,7 +45,6 @@ namespace BansheeEditor
             massField.Value = body.Mass;
             linearDragField.Value = body.Drag;
             angularDragField.Value = body.AngularDrag;
-            interpolationModeField.Value = (ulong)body.InterpolationMode;
             reportModeField.Value = (ulong) body.CollisionReportMode;
             ccdField.Value = (body.Flags & RigidbodyFlag.CCD) != 0;
 
@@ -96,14 +93,6 @@ namespace BansheeEditor
             angularDragField.OnConfirmed += ConfirmModify;
             angularDragField.OnFocusLost += ConfirmModify;
 
-            interpolationModeField.OnSelectionChanged += x =>
-            {
-                body.InterpolationMode = (RigidbodyInterpolationMode)x;
-
-                MarkAsModified();
-                ConfirmModify();
-            };
-
             reportModeField.OnSelectionChanged += x =>
             {
                 body.CollisionReportMode = (CollisionReportMode) x;
@@ -131,7 +120,6 @@ namespace BansheeEditor
             Layout.AddElement(massField);
             Layout.AddElement(linearDragField);
             Layout.AddElement(angularDragField);
-            Layout.AddElement(interpolationModeField);
             Layout.AddElement(reportModeField);
             Layout.AddElement(ccdField);
         }

+ 0 - 12
Source/MBansheeEngine/Physics/Interop/NativeRigidbody.cs

@@ -134,12 +134,6 @@ namespace BansheeEngine
             set { Internal_SetVelocitySolverCount(mCachedPtr, value); }
         }
 
-        public RigidbodyInterpolationMode InterpolationMode
-        {
-            get { return Internal_GetInterpolationMode(mCachedPtr); }
-            set { Internal_SetInterpolationMode(mCachedPtr, value); }
-        }
-
         public RigidbodyFlag Flags
         {
             get { return Internal_GetFlags(mCachedPtr); }
@@ -346,12 +340,6 @@ namespace BansheeEngine
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern int Internal_GetVelocitySolverCount(IntPtr thisPtr);
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetInterpolationMode(IntPtr thisPtr, RigidbodyInterpolationMode value);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern RigidbodyInterpolationMode Internal_GetInterpolationMode(IntPtr thisPtr);
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetFlags(IntPtr thisPtr, RigidbodyFlag flags);
 

+ 0 - 42
Source/MBansheeEngine/Physics/Rigidbody.cs

@@ -300,21 +300,6 @@ namespace BansheeEngine
             }
         }
 
-        /// <summary>
-        /// Determines interpolation mode that controls how is the rigidbody transfrom updated from the physics simulation.
-        /// </summary>
-        public RigidbodyInterpolationMode InterpolationMode
-        {
-            get { return serializableData.interpolationMode; }
-            set
-            {
-                serializableData.interpolationMode = value;
-
-                if (native != null)
-                    serializableData.interpolationMode = value;
-            }
-        }
-
         /// <summary>
         /// Determines which (if any) collision events are reported.
         /// </summary>
@@ -679,7 +664,6 @@ namespace BansheeEngine
             native.SleepThreshold = serializableData.sleepThreshold;
             native.UseGravity = serializableData.useGravity;
             native.Kinematic = serializableData.isKinematic;
-            native.InterpolationMode = serializableData.interpolationMode;
             native.Flags = serializableData.flags;
 
             if ((serializableData.flags & RigidbodyFlag.AutoTensors) == 0)
@@ -707,7 +691,6 @@ namespace BansheeEngine
             public int positionSolverCount = 4;
             public int velocitySolverCount = 1;
             public RigidbodyFlag flags = RigidbodyFlag.AutoTensors | RigidbodyFlag.AutoMass;
-            public RigidbodyInterpolationMode interpolationMode = RigidbodyInterpolationMode.None;
             public CollisionReportMode collisionReportMode = CollisionReportMode.None;
             public Vector3 centerMassPosition = Vector3.Zero;
             public Quaternion centerMassRotation = Quaternion.Identity;
@@ -785,30 +768,5 @@ namespace BansheeEngine
 		CCD = 0x04
     }
 
-    /// <summary>
-    /// Determines interpolation mode for a rigidbody transform during physics simulation.
-    /// </summary>
-    public enum RigidbodyInterpolationMode
-    {
-        /// <summary>
-        /// No interpolation is performed, physics transform is copied straight to the rigidbody when physics tick is done.
-        /// </summary>
-        None,
-        /// <summary>
-        /// Physics transfrom from the most recent tick is saved and slowly interpolated to during the following render 
-        /// frames. This can improve smoothness of the visible movement at framerates higher than the physics simulation 
-        /// but will introduce a delay of one physics tick to all such objects. This can create slight inconsistencies as
-        /// non-interpolated objects will have no such delay, as well as cause input lag due to the delayed reaction.
-        /// </summary>
-        Interpolate,
-        /// <summary>
-        /// Physics transform movement will be extrapolated from the last physics simulation tick. This will improve
-        /// smoothness of visible movement at framerates higher than the physics simulation. Unlike Interpolate it will
-        /// not introduce an input delay, but will introduce an error as the exact position/rotation of the objects is
-        /// extrapolated from the last frame's movement and velocities. 
-        /// </summary>
-        Extrapolate
-    }
-
     /** @} */
 }

+ 0 - 3
Source/SBansheeEngine/Include/BsScriptRigidbody.h

@@ -94,9 +94,6 @@ namespace BansheeEngine
 		static void internal_SetVelocitySolverCount(ScriptRigidbody* thisPtr, UINT32 count);
 		static UINT32 internal_GetVelocitySolverCount(ScriptRigidbody* thisPtr);
 
-		static void internal_SetInterpolationMode(ScriptRigidbody* thisPtr, Rigidbody::InterpolationMode value);
-		static Rigidbody::InterpolationMode internal_GetInterpolationMode(ScriptRigidbody* thisPtr);
-
 		static void internal_SetFlags(ScriptRigidbody* thisPtr, Rigidbody::Flag flags);
 		static Rigidbody::Flag internal_GetFlags(ScriptRigidbody* thisPtr);
 

+ 0 - 13
Source/SBansheeEngine/Source/BsScriptRigidbody.cpp

@@ -82,9 +82,6 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_SetVelocitySolverCount", &ScriptRigidbody::internal_SetVelocitySolverCount);
 		metaData.scriptClass->addInternalCall("Internal_GetVelocitySolverCount", &ScriptRigidbody::internal_GetVelocitySolverCount);
 
-		metaData.scriptClass->addInternalCall("Internal_SetInterpolationMode", &ScriptRigidbody::internal_SetInterpolationMode);
-		metaData.scriptClass->addInternalCall("Internal_GetInterpolationMode", &ScriptRigidbody::internal_GetInterpolationMode);
-
 		metaData.scriptClass->addInternalCall("Internal_SetFlags", &ScriptRigidbody::internal_SetFlags);
 		metaData.scriptClass->addInternalCall("Internal_GetFlags", &ScriptRigidbody::internal_GetFlags);
 
@@ -315,16 +312,6 @@ namespace BansheeEngine
 		return thisPtr->mRigidbody->getVelocitySolverCount();
 	}
 
-	void ScriptRigidbody::internal_SetInterpolationMode(ScriptRigidbody* thisPtr, Rigidbody::InterpolationMode value)
-	{
-		thisPtr->mRigidbody->setInterpolationMode(value);
-	}
-
-	Rigidbody::InterpolationMode ScriptRigidbody::internal_GetInterpolationMode(ScriptRigidbody* thisPtr)
-	{
-		return thisPtr->mRigidbody->getInterpolationMode();
-	}
-
 	void ScriptRigidbody::internal_SetFlags(ScriptRigidbody* thisPtr, Rigidbody::Flag flags)
 	{
 		thisPtr->mRigidbody->setFlags(flags);