Page MenuHome

T38587 related
ActivePublic

Authored by Bastien Montagne (mont29) on Apr 10 2014, 7:54 PM.
void BKE_object_dimensions_set(Object *ob, const float value[3])
{
BoundBox *bb = NULL;
bb = BKE_object_boundbox_get(ob);
if (bb) {
float obmat[4][4];
float scale[3], len[3];
int i = 3;
mat4_to_size(scale, ob->obmat);
len[0] = bb->vec[4][0] - bb->vec[0][0];
len[1] = bb->vec[2][1] - bb->vec[0][1];
len[2] = bb->vec[1][2] - bb->vec[0][2];
print_v3("value", value);
print_v3("scale", scale);
print_v3("ob->size", ob->size);
print_v3("len", len);
printf("\n");
while (i--) {
float l = len[i], s = scale[i], v = value[i];
if (l > 0.0f) {
if (ELEM(0.0f, s, ob->size[i])) {
ob->size[i] = v / l;
}
else {
ob->size[i] *= v / (l * fabsf(s));
}
}
}
BKE_object_where_is_calc_mat4(G.main->scene.first, ob, ob->obmat);
}
}

Event Timeline

Bastien Montagne (mont29) changed the title of this paste from untitled to T38587 related.
Bastien Montagne (mont29) updated the paste's language from autodetect to diff.
Bastien Montagne (mont29) updated the paste's language from diff to c.