/**** Radial Control ****/ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br, bool secondary) { ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture"); unsigned int *texcache; int side = 128; int half = side / 2; int i, j; curvemapping_initialize(br->curve); texcache = BKE_brush_gen_texture_cache(br, half, secondary); im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; for (i = 0; i < side; ++i) { for (j = 0; j < side; ++j) { float magn = sqrtf(pow2f(i - half) + pow2f(j - half)); im->rect_float[i * side + j] = BKE_brush_curve_strength_clamped(br, magn, half); } } /* Modulate curve with texture */ if (texcache) { for (i = 0; i < side; ++i) { for (j = 0; j < side; ++j) { const int col = texcache[i * side + j]; im->rect_float[i * side + j] *= (((char *)&col)[0] + ((char *)&col)[1] + ((char *)&col)[2]) / 3.0f / 255.0f; } } MEM_freeN(texcache); } return im; }
MINLINE float pow7f(float x) { return pow2f(pow3f(x)) * x; }
static void test_float (void) { /* Check that the value of FLT_MIN_EXP is well parenthesized. */ ASSERT ((FLT_MIN_EXP % 101111) == (FLT_MIN_EXP) % 101111); /* Check that the value of DBL_MIN_10_EXP is well parenthesized. */ ASSERT ((FLT_MIN_10_EXP % 101111) == (FLT_MIN_10_EXP) % 101111); /* Check that 'float' is as specified in IEEE 754. */ ASSERT (FLT_MANT_DIG == 24); ASSERT (FLT_MIN_EXP == -125); ASSERT (FLT_MAX_EXP == 128); /* Check the value of FLT_MIN_10_EXP. */ ASSERT (FLT_MIN_10_EXP == - (int) (- (FLT_MIN_EXP - 1) * 0.30103)); /* Check the value of FLT_DIG. */ ASSERT (FLT_DIG == (int) ((FLT_MANT_DIG - 1) * 0.30103)); /* Check the value of FLT_MIN_10_EXP. */ ASSERT (FLT_MIN_10_EXP == - (int) (- (FLT_MIN_EXP - 1) * 0.30103)); /* Check the value of FLT_MAX_10_EXP. */ ASSERT (FLT_MAX_10_EXP == (int) (FLT_MAX_EXP * 0.30103)); /* Check the value of FLT_MAX. */ { volatile float m = FLT_MAX; int n; ASSERT (m + m > m); for (n = 0; n <= 2 * FLT_MANT_DIG; n++) { volatile float pow2_n = pow2f (n); /* 2^n */ volatile float x = m + (m / pow2_n); if (x > m) ASSERT (x + x == x); else ASSERT (!(x + x == x)); } } /* Check the value of FLT_MIN. */ { volatile float m = FLT_MIN; volatile float x = pow2f (FLT_MIN_EXP - 1); ASSERT (m == x); } /* Check the value of FLT_EPSILON. */ { volatile float e = FLT_EPSILON; volatile float me; int n; me = 1.0f + e; ASSERT (me > 1.0f); ASSERT (me - 1.0f == e); for (n = 0; n <= 2 * FLT_MANT_DIG; n++) { volatile float half_n = pow2f (- n); /* 2^-n */ volatile float x = me - half_n; if (x < me) ASSERT (x <= 1.0f); } } }
MINLINE float pow4f(float x) { return pow2f(pow2f(x)); }