Pārlūkot izejas kodu

Refactor: Avoid redrawing curve & distribution GUI elements if the assigned value is the same as the current one

BearishSun 7 gadi atpakaļ
vecāks
revīzija
c99eb1f42d

+ 3 - 0
Source/EditorCore/GUI/BsGUIColorDistributionField.cpp

@@ -65,6 +65,9 @@ namespace bs
 
 	void GUIColorDistributionField::setValue(const ColorDistribution& value)
 	{
+		if(mValue == value)
+			return;
+
 		mValue = value;
 
 		switch (mPropertyType)

+ 3 - 1
Source/EditorCore/GUI/BsGUIColorGradient.cpp

@@ -49,8 +49,10 @@ namespace bs
 
 	void GUIColorGradient::setGradient(const ColorGradient& color)
 	{
-		mValue = color;
+		if(mValue == color)
+			return;
 
+		mValue = color;
 		_markContentAsDirty();
 	}
 

+ 3 - 0
Source/EditorCore/GUI/BsGUIColorGradientField.cpp

@@ -21,6 +21,9 @@ namespace bs
 
 	void GUIColorGradientField::setValue(const ColorGradient& gradient)
 	{
+		if(mValue == gradient)
+			return;
+
 		mValue = gradient;
 		mGradient->setGradient(gradient);
 	}

+ 3 - 0
Source/EditorCore/GUI/BsGUICurves.cpp

@@ -52,6 +52,9 @@ namespace bs
 
 	void GUICurves::setCurves(const Vector<CurveDrawInfo>& curves)
 	{
+		if(mCurves == curves)
+			return;
+
 		mCurves = curves;
 		_markContentAsDirty();
 	}

+ 3 - 0
Source/EditorCore/GUI/BsGUICurves.h

@@ -41,6 +41,9 @@ namespace bs
 
 		TAnimationCurve<float> curve;
 		Color color;
+
+		bool operator== (const CurveDrawInfo& rhs) const { return curve == rhs.curve && color == rhs.color; }
+		bool operator!= (const CurveDrawInfo& rhs) const { return !operator==(rhs); }
 	};
 
 	/** GUI element that displays one or multiple curves. */

+ 3 - 0
Source/EditorCore/GUI/BsGUIFloatDistributionField.cpp

@@ -80,6 +80,9 @@ namespace bs
 	template<class T, class SELF>
 	void TGUIDistributionField<T, SELF>::setValue(const TDistribution<T>& value)
 	{
+		if(mValue == value)
+			return;
+
 		mValue = value;
 
 		switch (mPropertyType)

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit b5b796fd21c1ca20a854aaa120fe24d6755022ea
+Subproject commit 34d587cb4e00ea1f1805b62176a71bab57741483