forked from bartvdbraak/blender
BLI_utildefines: add SQUARE macro
also minor cleanup
This commit is contained in:
parent
cc03689962
commit
a4258d40a1
@ -937,7 +937,7 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2],
|
||||
do {
|
||||
rand_pos[0] = BLI_rng_get_float(brush_rng) - 0.5f;
|
||||
rand_pos[1] = BLI_rng_get_float(brush_rng) - 0.5f;
|
||||
} while (len_squared_v2(rand_pos) > (0.5f * 0.5f));
|
||||
} while (len_squared_v2(rand_pos) > SQUARE(0.5f));
|
||||
|
||||
|
||||
if (brush->flag & BRUSH_ABSOLUTE_JITTER) {
|
||||
|
@ -1126,7 +1126,7 @@ static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
|
||||
}
|
||||
else {
|
||||
/* check for lower LoD */
|
||||
while (current->next && dist_sq > (current->next->distance * current->next->distance)) {
|
||||
while (current->next && dist_sq > SQUARE(current->next->distance)) {
|
||||
current = current->next;
|
||||
}
|
||||
}
|
||||
|
@ -309,10 +309,14 @@
|
||||
#define ABS(a) ({ \
|
||||
typeof(a) a_ = (a); \
|
||||
((a_) < 0 ? (-(a_)) : (a_)); })
|
||||
#define SQUARE(a) ({ \
|
||||
typeof(a) a_ = (a); \
|
||||
((a_) * (a_)); })
|
||||
|
||||
#else
|
||||
|
||||
#define ABS(a) ((a) < 0 ? (-(a)) : (a))
|
||||
#define SQUARE(a) ((a) * (a))
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -8747,13 +8747,12 @@ static int ui_handler_pie(bContext *C, const wmEvent *event, uiPopupBlockHandle
|
||||
if (!is_click_style) {
|
||||
float len_sq = len_squared_v2v2(event_xy, block->pie_data.pie_center_init);
|
||||
|
||||
if (len_sq > PIE_CLICK_THRESHOLD_SQ)
|
||||
{
|
||||
if (len_sq > PIE_CLICK_THRESHOLD_SQ) {
|
||||
block->pie_data.flags |= UI_PIE_DRAG_STYLE;
|
||||
}
|
||||
|
||||
if ((U.pie_menu_confirm >= U.pie_menu_threshold) &&
|
||||
(sqrtf(len_sq) >= U.pie_menu_confirm))
|
||||
(len_sq >= SQUARE(U.pie_menu_confirm)))
|
||||
{
|
||||
block->pie_data.flags |= UI_PIE_GESTURE_END_WAIT;
|
||||
copy_v2_v2(block->pie_data.last_pos, event_xy);
|
||||
|
@ -919,7 +919,7 @@ static float calc_vp_strength_col_dl(VPaint *vp, ViewContext *vc, const float co
|
||||
{
|
||||
const float dist_sq = len_squared_v2v2(mval, co_ss);
|
||||
|
||||
if (dist_sq <= brush_size_pressure * brush_size_pressure) {
|
||||
if (dist_sq <= SQUARE(brush_size_pressure)) {
|
||||
Brush *brush = BKE_paint_brush(&vp->paint);
|
||||
const float dist = sqrtf(dist_sq);
|
||||
float factor;
|
||||
|
@ -605,7 +605,7 @@ static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(
|
||||
static int node_tweak_area_reroute(bNode *node, int x, int y)
|
||||
{
|
||||
/* square of tweak radius */
|
||||
static const float tweak_radius_sq = 576; /* 24 * 24 */
|
||||
static const float tweak_radius_sq = SQUARE(24);
|
||||
|
||||
bNodeSocket *sock = node->inputs.first;
|
||||
float dx = sock->locx - x;
|
||||
|
@ -249,7 +249,7 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
|
||||
}
|
||||
|
||||
dist_sq = len_squared_v3(vec);
|
||||
if ((tob->rdist == -1.0f) || (dist_sq < (tob->rdist * tob->rdist))) {
|
||||
if ((tob->rdist == -1.0f) || (dist_sq < SQUARE(tob->rdist))) {
|
||||
tob->rdist = sqrtf(dist_sq);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user