bool BKE_mball_minmax_ex(MetaBall *mb, float min[3], float max[3], float obmat[4][4], const short flag) { const float scale = obmat ? mat4_to_scale(obmat) : 1.0f; MetaElem *ml; bool changed = false; float centroid[3], vec[3]; INIT_MINMAX(min, max); for (ml = mb->elems.first; ml; ml = ml->next) { if ((ml->flag & flag) == flag) { const float scale_mb = (ml->rad * 0.5f) * scale; int i; if (obmat) { mul_v3_m4v3(centroid, obmat, &ml->x); } else { copy_v3_v3(centroid, &ml->x); } /* TODO, non circle shapes cubes etc, probably nobody notices - campbell */ for (i = -1; i != 3; i += 2) { copy_v3_v3(vec, centroid); add_v3_fl(vec, scale_mb * i); minmax_v3v3_v3(min, max, vec); } changed = true; } } return changed; }
void strand_minmax(StrandRen *strand, float min[3], float max[3], const float width) { StrandVert *svert; const float width2 = width * 2.0f; float vec[3]; int a; for (a=0, svert=strand->vert; a<strand->totvert; a++, svert++) { copy_v3_v3(vec, svert->co); minmax_v3v3_v3(min, max, vec); if (width!=0.0f) { add_v3_fl(vec, width); minmax_v3v3_v3(min, max, vec); add_v3_fl(vec, -width2); minmax_v3v3_v3(min, max, vec); } } }