DNA: rename Object.size -> scale

Resolves a common cause of confusion.
This commit is contained in:
Campbell Barton 2019-02-18 15:43:06 +11:00
parent 4719e7ec7a
commit cc10d86535
23 changed files with 71 additions and 71 deletions

View File

@ -193,7 +193,7 @@ void BKE_object_tfm_restore(struct Object *ob, void *obtfm_pt);
typedef struct ObjectTfmProtectedChannels {
float loc[3], dloc[3];
float size[3], dscale[3];
float scale[3], dscale[3];
float rot[3], drot[3];
float quat[4], dquat[4];
float rotAxis[3], drotAxis[3];

View File

@ -1090,7 +1090,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar
float size[3], vec[3];
float totmat[3][3];
/* Get size property, since ob->size is only the object's own relative size, not its global one */
/* Get size property, since ob->scale is only the object's own relative size, not its global one */
mat4_to_size(size, cob->matrix);
/* Clear the object's rotation */

View File

@ -1851,8 +1851,8 @@ void BKE_curve_bevel_make(
bevcu = cu->bevobj->data;
if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) {
ListBase bevdisp = {NULL, NULL};
facx = cu->bevobj->size[0];
facy = cu->bevobj->size[1];
facx = cu->bevobj->scale[0];
facy = cu->bevobj->scale[1];
if (for_render) {
if (BLI_linklist_index(ob_cyclic_list, cu->bevobj) == -1) {

View File

@ -5715,7 +5715,7 @@ static void dynamic_paint_generate_bake_data_cb(
/* Prepare surface normal directional scale to easily convert
* brush intersection amount between global and local space */
float scaled_nor[3];
mul_v3_v3v3(scaled_nor, temp_nor, ob->size);
mul_v3_v3v3(scaled_nor, temp_nor, ob->scale);
bData->bNormal[index].normal_scale = len_v3(scaled_nor);
}
mul_mat3_m4_v3(ob->obmat, temp_nor);
@ -5752,7 +5752,7 @@ static void dynamic_paint_generate_bake_data_cb(
/* Prepare surface normal directional scale to easily convert
* brush intersection amount between global and local space */
float scaled_nor[3];
mul_v3_v3v3(scaled_nor, temp_nor, ob->size);
mul_v3_v3v3(scaled_nor, temp_nor, ob->scale);
bData->bNormal[index].normal_scale = len_v3(scaled_nor);
}
mul_mat3_m4_v3(ob->obmat, temp_nor);

View File

@ -1249,9 +1249,9 @@ void BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob, ListBa
/* don't polygonize metaballs with too high resolution (base mball to small)
* note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */
if (ob->size[0] > 0.00001f * (process.allbb.max[0] - process.allbb.min[0]) ||
ob->size[1] > 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) ||
ob->size[2] > 0.00001f * (process.allbb.max[2] - process.allbb.min[2]))
if (ob->scale[0] > 0.00001f * (process.allbb.max[0] - process.allbb.min[0]) ||
ob->scale[1] > 0.00001f * (process.allbb.max[1] - process.allbb.min[1]) ||
ob->scale[2] > 0.00001f * (process.allbb.max[2] - process.allbb.min[2]))
{
polygonize(&process);

View File

@ -151,7 +151,7 @@ void BKE_object_workob_clear(Object *workob)
{
memset(workob, 0, sizeof(Object));
workob->size[0] = workob->size[1] = workob->size[2] = 1.0f;
workob->scale[0] = workob->scale[1] = workob->scale[2] = 1.0f;
workob->dscale[0] = workob->dscale[1] = workob->dscale[2] = 1.0f;
workob->rotmode = ROT_MODE_EUL;
}
@ -816,7 +816,7 @@ void BKE_object_init(Object *ob)
ob->col[0] = ob->col[1] = ob->col[2] = 1.0;
ob->col[3] = 1.0;
ob->size[0] = ob->size[1] = ob->size[2] = 1.0;
ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0;
ob->dscale[0] = ob->dscale[1] = ob->dscale[2] = 1.0;
/* objects should default to having Euler XYZ rotations,
@ -1306,7 +1306,7 @@ void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src)
copy_v3_v3(ob_tar->rotAxis, ob_src->rotAxis);
ob_tar->rotAngle = ob_src->rotAngle;
ob_tar->rotmode = ob_src->rotmode;
copy_v3_v3(ob_tar->size, ob_src->size);
copy_v3_v3(ob_tar->scale, ob_src->scale);
}
/**
@ -1712,7 +1712,7 @@ void BKE_object_obdata_size_init(struct Object *ob, const float size)
void BKE_object_scale_to_mat3(Object *ob, float mat[3][3])
{
float vec[3];
mul_v3_v3v3(vec, ob->size, ob->dscale);
mul_v3_v3v3(vec, ob->scale, ob->dscale);
size_to_mat3(mat, vec);
}
@ -1809,7 +1809,7 @@ void BKE_object_tfm_protected_backup(const Object *ob,
TFMCPY3D(loc);
TFMCPY3D(dloc);
TFMCPY3D(size);
TFMCPY3D(scale);
TFMCPY3D(dscale);
TFMCPY3D(rot);
TFMCPY3D(drot);
@ -1839,7 +1839,7 @@ void BKE_object_tfm_protected_restore(Object *ob,
}
if (protectflag & (OB_LOCK_SCALEX << i)) {
ob->size[i] = obtfm->size[i];
ob->scale[i] = obtfm->scale[i];
ob->dscale[i] = obtfm->dscale[i];
}
@ -1870,7 +1870,7 @@ void BKE_object_to_mat3(Object *ob, float mat[3][3]) /* no parent */
float rmat[3][3];
/*float q1[4];*/
/* size */
/* scale */
BKE_object_scale_to_mat3(ob, smat);
/* rot */
@ -2326,19 +2326,19 @@ void BKE_object_apply_mat4_ex(Object *ob, float mat[4][4], Object *parent, float
mul_m4_m4m4(rmat, imat, mat); /* get the parent relative matrix */
/* same as below, use rmat rather than mat */
mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat);
mat4_to_loc_rot_size(ob->loc, rot, ob->scale, rmat);
}
else {
mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat);
mat4_to_loc_rot_size(ob->loc, rot, ob->scale, mat);
}
BKE_object_mat3_to_rot(ob, rot, use_compat);
sub_v3_v3(ob->loc, ob->dloc);
if (ob->dscale[0] != 0.0f) ob->size[0] /= ob->dscale[0];
if (ob->dscale[1] != 0.0f) ob->size[1] /= ob->dscale[1];
if (ob->dscale[2] != 0.0f) ob->size[2] /= ob->dscale[2];
if (ob->dscale[0] != 0.0f) ob->scale[0] /= ob->dscale[0];
if (ob->dscale[1] != 0.0f) ob->scale[1] /= ob->dscale[1];
if (ob->dscale[2] != 0.0f) ob->scale[2] /= ob->dscale[2];
/* BKE_object_mat3_to_rot handles delta rotations */
}
@ -2491,7 +2491,7 @@ void BKE_object_dimensions_set(Object *ob, const float value[3], int axis_mask)
for (int i = 0; i < 3; i++) {
if (((1 << i) & axis_mask) == 0) {
if (len[i] > 0.0f) {
ob->size[i] = copysignf(value[i] / len[i], ob->size[i]);
ob->scale[i] = copysignf(value[i] / len[i], ob->scale[i]);
}
}
}
@ -2563,7 +2563,7 @@ void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3], const bool us
if (changed == false) {
float size[3];
copy_v3_v3(size, ob->size);
copy_v3_v3(size, ob->scale);
if ((ob->type == OB_EMPTY) || (ob->type == OB_GPENCIL)) {
mul_v3_fl(size, ob->empty_drawsize);
}
@ -2752,7 +2752,7 @@ void *BKE_object_tfm_backup(Object *ob)
copy_v3_v3(obtfm->loc, ob->loc);
copy_v3_v3(obtfm->dloc, ob->dloc);
copy_v3_v3(obtfm->orig, ob->orig);
copy_v3_v3(obtfm->size, ob->size);
copy_v3_v3(obtfm->size, ob->scale);
copy_v3_v3(obtfm->dscale, ob->dscale);
copy_v3_v3(obtfm->rot, ob->rot);
copy_v3_v3(obtfm->drot, ob->drot);
@ -2776,7 +2776,7 @@ void BKE_object_tfm_restore(Object *ob, void *obtfm_pt)
copy_v3_v3(ob->loc, obtfm->loc);
copy_v3_v3(ob->dloc, obtfm->dloc);
copy_v3_v3(ob->orig, obtfm->orig);
copy_v3_v3(ob->size, obtfm->size);
copy_v3_v3(ob->scale, obtfm->size);
copy_v3_v3(ob->dscale, obtfm->dscale);
copy_v3_v3(ob->rot, obtfm->rot);
copy_v3_v3(ob->drot, obtfm->drot);

View File

@ -225,7 +225,7 @@ static void smoke_set_domain_from_mesh(SmokeDomainSettings *sds, Object *ob, Mes
}
/* apply object scale */
for (i = 0; i < 3; i++) {
size[i] = fabsf(size[i] * ob->size[i]);
size[i] = fabsf(size[i] * ob->scale[i]);
}
copy_v3_v3(sds->global_size, size);
copy_v3_v3(sds->dp0, min);
@ -239,21 +239,21 @@ static void smoke_set_domain_from_mesh(SmokeDomainSettings *sds, Object *ob, Mes
/* define grid resolutions from longest domain side */
if (size[0] >= MAX2(size[1], size[2])) {
scale = res / size[0];
sds->scale = size[0] / fabsf(ob->size[0]);
sds->scale = size[0] / fabsf(ob->scale[0]);
sds->base_res[0] = res;
sds->base_res[1] = max_ii((int)(size[1] * scale + 0.5f), 4);
sds->base_res[2] = max_ii((int)(size[2] * scale + 0.5f), 4);
}
else if (size[1] >= MAX2(size[0], size[2])) {
scale = res / size[1];
sds->scale = size[1] / fabsf(ob->size[1]);
sds->scale = size[1] / fabsf(ob->scale[1]);
sds->base_res[0] = max_ii((int)(size[0] * scale + 0.5f), 4);
sds->base_res[1] = res;
sds->base_res[2] = max_ii((int)(size[2] * scale + 0.5f), 4);
}
else {
scale = res / size[2];
sds->scale = size[2] / fabsf(ob->size[2]);
sds->scale = size[2] / fabsf(ob->scale[2]);
sds->base_res[0] = max_ii((int)(size[0] * scale + 0.5f), 4);
sds->base_res[1] = max_ii((int)(size[1] * scale + 0.5f), 4);
sds->base_res[2] = res;

View File

@ -783,13 +783,13 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain)
int i;
for (i = 0; i < 3; i++) {
if ( (ob->dsize[i] == 0.0f) || /* simple case, user never touched dsize */
(ob->size[i] == 0.0f)) /* cant scale the dsize to give a non zero result,
(ob->scale[i] == 0.0f)) /* cant scale the dsize to give a non zero result,
* so fallback to 1.0f */
{
ob->dscale[i] = 1.0f;
}
else {
ob->dscale[i] = (ob->size[i] + ob->dsize[i]) / ob->size[i];
ob->dscale[i] = (ob->scale[i] + ob->dsize[i]) / ob->scale[i];
}
}
}

View File

@ -1938,7 +1938,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
job->lay = BKE_scene_base_find(scene, job)->lay = 2;
mul_v3_fl(job->size, 0.5f);
mul_v3_fl(job->scale, 0.5f);
DEG_id_tag_update(&job->id, ID_RECALC_TRANSFORM);
verify_adt_action((ID *)&job->id, 1);
@ -1955,7 +1955,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
mul_m4_m4m4(mat, ipar, temp);
}
bc_decompose(mat, job->loc, NULL, job->quat, job->size);
bc_decompose(mat, job->loc, NULL, job->quat, job->scale);
if (par_job) {
job->parent = par_job;

View File

@ -70,11 +70,11 @@ void TransformWriter::add_node_transform_ob(
// factor out scale from obmat
copy_v3_v3(scale, ob->size);
copy_v3_v3(scale, ob->scale);
ob->size[0] = ob->size[1] = ob->size[2] = 1.0f;
ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f;
BKE_object_to_mat4(ob, C);
copy_v3_v3(ob->size, scale);
copy_v3_v3(ob->scale, scale);
mul_m4_series(tmat, ob->parent->obmat, ob->parentinv, C);
@ -91,7 +91,7 @@ void TransformWriter::add_node_transform_ob(
else {
copy_v3_v3(loc, ob->loc);
copy_v3_v3(rot, ob->rot);
copy_v3_v3(scale, ob->size);
copy_v3_v3(scale, ob->scale);
}
add_transform(node, loc, rot, scale);

View File

@ -714,7 +714,7 @@ static void gp_draw_stroke_3d(tGPDdraw *tgpw, short thickness, const float ink[4
immBindBuiltinProgram(GPU_SHADER_GPENCIL_STROKE);
immUniform2fv("Viewport", viewport);
immUniform1f("pixsize", tgpw->rv3d->pixsize);
float obj_scale = tgpw->ob ? (tgpw->ob->size[0] + tgpw->ob->size[1] + tgpw->ob->size[2]) / 3.0f : 1.0f;
float obj_scale = tgpw->ob ? (tgpw->ob->scale[0] + tgpw->ob->scale[1] + tgpw->ob->scale[2]) / 3.0f : 1.0f;
immUniform1f("objscale", obj_scale);
int keep_size = (int)((tgpw->gpd) && (tgpw->gpd->flag & GP_DATA_STROKE_KEEPTHICKNESS));

View File

@ -440,7 +440,7 @@ static int object_add_exec(bContext *C, wmOperator *op)
if (ob->type == OB_LATTICE) {
/* lattice is a special case!
* we never want to scale the obdata since that is the rest-state */
copy_v3_fl(ob->size, radius);
copy_v3_fl(ob->scale, radius);
}
else {
BKE_object_obdata_size_init(ob, radius);

View File

@ -222,15 +222,15 @@ static void object_clear_scale(Object *ob, const bool clear_delta)
{
/* clear scale factors which are not locked */
if ((ob->protectflag & OB_LOCK_SCALEX) == 0) {
ob->size[0] = 1.0f;
ob->scale[0] = 1.0f;
if (clear_delta) ob->dscale[0] = 1.0f;
}
if ((ob->protectflag & OB_LOCK_SCALEY) == 0) {
ob->size[1] = 1.0f;
ob->scale[1] = 1.0f;
if (clear_delta) ob->dscale[1] = 1.0f;
}
if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) {
ob->size[2] = 1.0f;
ob->scale[2] = 1.0f;
if (clear_delta) ob->dscale[2] = 1.0f;
}
}
@ -630,7 +630,7 @@ static int apply_objects_internal(
continue;
if (apply_scale)
BKE_tracking_reconstruction_scale(&clip->tracking, ob->size);
BKE_tracking_reconstruction_scale(&clip->tracking, ob->scale);
}
else if (ob->type == OB_EMPTY) {
/* It's possible for empties too, even though they don't
@ -649,7 +649,7 @@ static int apply_objects_internal(
(apply_rot == false) &&
(apply_scale == true))
{
float max_scale = max_fff(fabsf(ob->size[0]), fabsf(ob->size[1]), fabsf(ob->size[2]));
float max_scale = max_fff(fabsf(ob->scale[0]), fabsf(ob->scale[1]), fabsf(ob->scale[2]));
ob->empty_drawsize *= max_scale;
}
}
@ -680,7 +680,7 @@ static int apply_objects_internal(
if (apply_loc)
zero_v3(ob->loc);
if (apply_scale)
ob->size[0] = ob->size[1] = ob->size[2] = 1.0f;
ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f;
if (apply_rot) {
zero_v3(ob->rot);
unit_qt(ob->quat);
@ -1402,10 +1402,10 @@ static void object_apply_rotation(Object *ob, const float rmat[3][3])
float rmat4[4][4];
copy_m4_m3(rmat4, rmat);
copy_v3_v3(size, ob->size);
copy_v3_v3(size, ob->scale);
copy_v3_v3(loc, ob->loc);
BKE_object_apply_mat4(ob, rmat4, true, true);
copy_v3_v3(ob->size, size);
copy_v3_v3(ob->scale, size);
copy_v3_v3(ob->loc, loc);
}
/* We may want to extract this to: BKE_object_apply_location */

View File

@ -438,7 +438,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC);
set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC);
set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC);
set_channel(fobj->Scale, timeAtFrame, ob->scale, i, CHANNEL_VEC);
set_channel(fobj->Active, timeAtFrame, &active, i, CHANNEL_FLOAT);
set_channel(fobj->InitialVelocity, timeAtFrame, &fluidmd->fss->iniVelx, i, CHANNEL_VEC);

View File

@ -4412,12 +4412,12 @@ static void sculpt_update_cache_invariants(
else {
max_scale = 0.0f;
for (i = 0; i < 3; i ++) {
max_scale = max_ff(max_scale, fabsf(ob->size[i]));
max_scale = max_ff(max_scale, fabsf(ob->scale[i]));
}
}
cache->scale[0] = max_scale / ob->size[0];
cache->scale[1] = max_scale / ob->size[1];
cache->scale[2] = max_scale / ob->size[2];
cache->scale[0] = max_scale / ob->scale[0];
cache->scale[1] = max_scale / ob->scale[1];
cache->scale[2] = max_scale / ob->scale[2];
cache->plane_trim_squared = brush->plane_trim * brush->plane_trim;
@ -5881,7 +5881,7 @@ void ED_object_sculptmode_enter_ex(
BKE_sculpt_mask_layers_ensure(ob, mmd);
}
if (!(fabsf(ob->size[0] - ob->size[1]) < 1e-4f && fabsf(ob->size[1] - ob->size[2]) < 1e-4f)) {
if (!(fabsf(ob->scale[0] - ob->scale[1]) < 1e-4f && fabsf(ob->scale[1] - ob->scale[2]) < 1e-4f)) {
BKE_report(reports, RPT_WARNING,
"Object has non-uniform scale, sculpting may be unpredictable");
}

View File

@ -670,18 +670,18 @@ static int do_set_scale(bContext *C,
}
else {
if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
mul_v3_fl(object->size, scale);
mul_v3_fl(object->scale, scale);
mul_v3_fl(object->loc, scale);
}
else if (!scale_solution) {
Object *solver_camera = object_solver_camera(scene, object);
object->size[0] = object->size[1] = object->size[2] = 1.0f / scale;
object->scale[0] = object->scale[1] = object->scale[2] = 1.0f / scale;
if (solver_camera) {
object->size[0] /= solver_camera->size[0];
object->size[1] /= solver_camera->size[1];
object->size[2] /= solver_camera->size[2];
object->scale[0] /= solver_camera->scale[0];
object->scale[1] /= solver_camera->scale[1];
object->scale[2] /= solver_camera->scale[2];
}
}
else {

View File

@ -251,21 +251,21 @@ void ED_view3d_cameracontrol_update(
}
else {
float view_mat[4][4];
float size_mat[4][4];
float size_back[3];
float scale_mat[4][4];
float scale_back[3];
/* even though we handle the size matrix, this still changes over time */
copy_v3_v3(size_back, v3d->camera->size);
/* even though we handle the scale matrix, this still changes over time */
copy_v3_v3(scale_back, v3d->camera->scale);
ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist);
size_to_mat4(size_mat, v3d->camera->size);
mul_m4_m4m4(view_mat, view_mat, size_mat);
size_to_mat4(scale_mat, v3d->camera->scale);
mul_m4_m4m4(view_mat, view_mat, scale_mat);
BKE_object_apply_mat4(v3d->camera, view_mat, true, true);
DEG_id_tag_update(&v3d->camera->id, ID_RECALC_TRANSFORM);
copy_v3_v3(v3d->camera->size, size_back);
copy_v3_v3(v3d->camera->scale, scale_back);
id_key = &v3d->camera->id;
}

View File

@ -174,7 +174,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
/* account for lens shifting */
offset[0] = ((ob->size[0] > 0.0f) ? -2.0f : 2.0f) * ca->shiftx;
offset[0] = ((ob->scale[0] > 0.0f) ? -2.0f : 2.0f) * ca->shiftx;
offset[1] = 2.0f * ca->shifty;
offset[2] = 0.0f;

View File

@ -5826,8 +5826,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
}
td->ext->rotOrder = ob->rotmode;
td->ext->size = ob->size;
copy_v3_v3(td->ext->isize, ob->size);
td->ext->size = ob->scale;
copy_v3_v3(td->ext->isize, ob->scale);
copy_v3_v3(td->ext->dscale, ob->dscale);
copy_v3_v3(td->center, ob->obmat[3]);

View File

@ -228,7 +228,7 @@ typedef struct Object {
/* rot en drot have to be together! (transform('r' en 's')) */
float loc[3], dloc[3], orig[3];
/** Scale in fact. */
float size[3];
float scale[3];
/** DEPRECATED, 2.60 and older only. */
float dsize[3] DNA_DEPRECATED ;
/** Ack!, changing. */

View File

@ -60,6 +60,7 @@ DNA_STRUCT_RENAME_ELEM(Camera, clipsta, clip_start)
DNA_STRUCT_RENAME_ELEM(Collection, dupli_ofs, instance_offset)
DNA_STRUCT_RENAME_ELEM(Object, dup_group, instance_collection)
DNA_STRUCT_RENAME_ELEM(Object, dupfacesca, instance_faces_scale)
DNA_STRUCT_RENAME_ELEM(Object, size, scale)
DNA_STRUCT_RENAME_ELEM(ParticleSettings, dup_group, instance_collection)
DNA_STRUCT_RENAME_ELEM(ParticleSettings, dup_ob, instance_object)
DNA_STRUCT_RENAME_ELEM(ParticleSettings, dupliweights, instance_weights)

View File

@ -2290,7 +2290,6 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Object_internal_update");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
RNA_def_property_editable_array_func(prop, "rna_Object_scale_editable");

View File

@ -62,7 +62,7 @@ static void generate_vert_coordinates(
if (r_size != NULL) {
if (ob_center != NULL) {
/* Not we are not interested in signs here - they are even troublesome actually, due to security clamping! */
abs_v3_v3(r_size, ob_center->size);
abs_v3_v3(r_size, ob_center->scale);
}
else {
/* Set size. */