瀏覽代碼

Added invSmoothStep.

Бранимир Караџић 5 年之前
父節點
當前提交
279b8ff3c0
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 5 0
      include/bx/inline/math.inl
  2. 3 0
      include/bx/math.h

+ 5 - 0
include/bx/inline/math.inl

@@ -344,6 +344,11 @@ namespace bx
 		return square(_a)*(3.0f - 2.0f*_a);
 	}
 
+	inline BX_CONST_FUNC float invSmoothStep(float _a)
+	{
+		return 0.5f - sin(asin(1.0f - 2.0f * _a) / 3.0f);
+	}
+
 	inline BX_CONSTEXPR_FUNC float bias(float _time, float _bias)
 	{
 		return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f);

+ 3 - 0
include/bx/math.h

@@ -282,6 +282,9 @@ namespace bx
 	///
 	BX_CONSTEXPR_FUNC float smoothStep(float _a);
 
+	///
+	BX_CONST_FUNC float invSmoothStep(float _a);
+
 	///
 	BX_CONSTEXPR_FUNC float bias(float _time, float _bias);