Cleanup: rename Mesh/Curve/MetaBall loc/size/texflag

Struct members loc/size were misleading as they read as if the object
data stored object level transform channels. Rename these to match RNA
with a `texspace_*` prefix to make it clear these struct members only
apply to texture-space transform.

Also rename ME_AUTOSPACE & ME_AUTOSPACE_EVALUATED to
ME_TEXSPACE_FLAG_AUTO & ME_TEXSPACE_FLAG_AUTO_EVALUATED.
This commit is contained in:
Campbell Barton 2023-01-18 17:17:32 +11:00
parent 07af7e2266
commit 9e5e2aa775
22 changed files with 221 additions and 198 deletions

View File

@ -247,11 +247,13 @@ struct BoundBox *BKE_mesh_boundbox_get(struct Object *ob);
void BKE_mesh_texspace_calc(struct Mesh *me);
void BKE_mesh_texspace_ensure(struct Mesh *me);
void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_size[3]);
void BKE_mesh_texspace_get(struct Mesh *me,
float r_texspace_location[3],
float r_texspace_size[3]);
void BKE_mesh_texspace_get_reference(struct Mesh *me,
char **r_texflag,
float **r_loc,
float **r_size);
char **r_texspace_flag,
float **r_texspace_location,
float **r_texspace_size);
void BKE_mesh_texspace_copy_from_object(struct Mesh *me, struct Object *ob);
/**

View File

@ -507,9 +507,9 @@ void BKE_object_handle_update_ex(struct Depsgraph *depsgraph,
void BKE_object_sculpt_data_create(struct Object *ob);
bool BKE_object_obdata_texspace_get(struct Object *ob,
char **r_texflag,
float **r_loc,
float **r_size);
char **r_texspace_flag,
float **r_texspace_location,
float **r_texspace_size);
struct Mesh *BKE_object_get_evaluated_mesh_no_subsurf(const struct Object *object);
/** Get evaluated mesh for given object. */

View File

@ -258,7 +258,7 @@ static void curve_blend_read_data(BlendDataReader *reader, ID *id)
switch_endian_knots(nu);
}
}
cu->texflag &= ~CU_AUTOSPACE_EVALUATED;
cu->texspace_flag &= ~CU_TEXSPACE_FLAG_AUTO_EVALUATED;
BLO_read_data_address(reader, &cu->bevel_profile);
if (cu->bevel_profile != nullptr) {
@ -517,7 +517,7 @@ BoundBox *BKE_curve_boundbox_get(Object *ob)
void BKE_curve_texspace_calc(Curve *cu)
{
if (cu->texflag & CU_AUTOSPACE) {
if (cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO) {
float min[3], max[3];
INIT_MINMAX(min, max);
@ -526,35 +526,36 @@ void BKE_curve_texspace_calc(Curve *cu)
max[0] = max[1] = max[2] = 1.0f;
}
float loc[3], size[3];
mid_v3_v3v3(loc, min, max);
float texspace_location[3], texspace_size[3];
mid_v3_v3v3(texspace_location, min, max);
size[0] = (max[0] - min[0]) / 2.0f;
size[1] = (max[1] - min[1]) / 2.0f;
size[2] = (max[2] - min[2]) / 2.0f;
texspace_size[0] = (max[0] - min[0]) / 2.0f;
texspace_size[1] = (max[1] - min[1]) / 2.0f;
texspace_size[2] = (max[2] - min[2]) / 2.0f;
for (int a = 0; a < 3; a++) {
if (size[a] == 0.0f) {
size[a] = 1.0f;
if (texspace_size[a] == 0.0f) {
texspace_size[a] = 1.0f;
}
else if (size[a] > 0.0f && size[a] < 0.00001f) {
size[a] = 0.00001f;
else if (texspace_size[a] > 0.0f && texspace_size[a] < 0.00001f) {
texspace_size[a] = 0.00001f;
}
else if (size[a] < 0.0f && size[a] > -0.00001f) {
size[a] = -0.00001f;
else if (texspace_size[a] < 0.0f && texspace_size[a] > -0.00001f) {
texspace_size[a] = -0.00001f;
}
}
copy_v3_v3(cu->loc, loc);
copy_v3_v3(cu->size, size);
copy_v3_v3(cu->texspace_location, texspace_location);
copy_v3_v3(cu->texspace_size, texspace_size);
cu->texflag |= CU_AUTOSPACE_EVALUATED;
cu->texspace_flag |= CU_TEXSPACE_FLAG_AUTO_EVALUATED;
}
}
void BKE_curve_texspace_ensure(Curve *cu)
{
if ((cu->texflag & CU_AUTOSPACE) && !(cu->texflag & CU_AUTOSPACE_EVALUATED)) {
if ((cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO) &&
(cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO_EVALUATED) == 0) {
BKE_curve_texspace_calc(cu);
}
}
@ -5508,10 +5509,10 @@ void BKE_curve_eval_geometry(Depsgraph *depsgraph, Curve *curve)
BKE_curve_texspace_calc(curve);
if (DEG_is_active(depsgraph)) {
Curve *curve_orig = (Curve *)DEG_get_original_id(&curve->id);
if (curve->texflag & CU_AUTOSPACE_EVALUATED) {
curve_orig->texflag |= CU_AUTOSPACE_EVALUATED;
copy_v3_v3(curve_orig->loc, curve->loc);
copy_v3_v3(curve_orig->size, curve->size);
if (curve->texspace_flag & CU_TEXSPACE_FLAG_AUTO_EVALUATED) {
curve_orig->texspace_flag |= CU_TEXSPACE_FLAG_AUTO_EVALUATED;
copy_v3_v3(curve_orig->texspace_location, curve->texspace_location);
copy_v3_v3(curve_orig->texspace_size, curve->texspace_size);
}
}
}

View File

@ -360,7 +360,7 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
BLO_read_data_address(reader, &mesh->active_color_attribute);
BLO_read_data_address(reader, &mesh->default_color_attribute);
mesh->texflag &= ~ME_AUTOSPACE_EVALUATED;
mesh->texspace_flag &= ~ME_TEXSPACE_FLAG_AUTO_EVALUATED;
mesh->edit_mesh = nullptr;
mesh->runtime = new blender::bke::MeshRuntime();
@ -1029,9 +1029,9 @@ void BKE_mesh_copy_parameters(Mesh *me_dst, const Mesh *me_src)
me_dst->face_sets_color_default = me_src->face_sets_color_default;
/* Copy texture space. */
me_dst->texflag = me_src->texflag;
copy_v3_v3(me_dst->loc, me_src->loc);
copy_v3_v3(me_dst->size, me_src->size);
me_dst->texspace_flag = me_src->texspace_flag;
copy_v3_v3(me_dst->texspace_location, me_src->texspace_location);
copy_v3_v3(me_dst->texspace_size, me_src->texspace_size);
me_dst->vertex_group_active_index = me_src->vertex_group_active_index;
me_dst->attributes_active_index = me_src->attributes_active_index;
@ -1228,7 +1228,7 @@ BoundBox *BKE_mesh_boundbox_get(Object *ob)
void BKE_mesh_texspace_calc(Mesh *me)
{
if (me->texflag & ME_AUTOSPACE) {
if (me->texspace_flag & ME_TEXSPACE_FLAG_AUTO) {
float min[3], max[3];
INIT_MINMAX(min, max);
@ -1237,75 +1237,79 @@ void BKE_mesh_texspace_calc(Mesh *me)
max[0] = max[1] = max[2] = 1.0f;
}
float loc[3], size[3];
mid_v3_v3v3(loc, min, max);
float texspace_location[3], texspace_size[3];
mid_v3_v3v3(texspace_location, min, max);
size[0] = (max[0] - min[0]) / 2.0f;
size[1] = (max[1] - min[1]) / 2.0f;
size[2] = (max[2] - min[2]) / 2.0f;
texspace_size[0] = (max[0] - min[0]) / 2.0f;
texspace_size[1] = (max[1] - min[1]) / 2.0f;
texspace_size[2] = (max[2] - min[2]) / 2.0f;
for (int a = 0; a < 3; a++) {
if (size[a] == 0.0f) {
size[a] = 1.0f;
if (texspace_size[a] == 0.0f) {
texspace_size[a] = 1.0f;
}
else if (size[a] > 0.0f && size[a] < 0.00001f) {
size[a] = 0.00001f;
else if (texspace_size[a] > 0.0f && texspace_size[a] < 0.00001f) {
texspace_size[a] = 0.00001f;
}
else if (size[a] < 0.0f && size[a] > -0.00001f) {
size[a] = -0.00001f;
else if (texspace_size[a] < 0.0f && texspace_size[a] > -0.00001f) {
texspace_size[a] = -0.00001f;
}
}
copy_v3_v3(me->loc, loc);
copy_v3_v3(me->size, size);
copy_v3_v3(me->texspace_location, texspace_location);
copy_v3_v3(me->texspace_size, texspace_size);
me->texflag |= ME_AUTOSPACE_EVALUATED;
me->texspace_flag |= ME_TEXSPACE_FLAG_AUTO_EVALUATED;
}
}
void BKE_mesh_texspace_ensure(Mesh *me)
{
if ((me->texflag & ME_AUTOSPACE) && !(me->texflag & ME_AUTOSPACE_EVALUATED)) {
if ((me->texspace_flag & ME_TEXSPACE_FLAG_AUTO) &&
!(me->texspace_flag & ME_TEXSPACE_FLAG_AUTO_EVALUATED)) {
BKE_mesh_texspace_calc(me);
}
}
void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_size[3])
void BKE_mesh_texspace_get(Mesh *me, float r_texspace_location[3], float r_texspace_size[3])
{
BKE_mesh_texspace_ensure(me);
if (r_loc) {
copy_v3_v3(r_loc, me->loc);
if (r_texspace_location) {
copy_v3_v3(r_texspace_location, me->texspace_location);
}
if (r_size) {
copy_v3_v3(r_size, me->size);
if (r_texspace_size) {
copy_v3_v3(r_texspace_size, me->texspace_size);
}
}
void BKE_mesh_texspace_get_reference(Mesh *me, char **r_texflag, float **r_loc, float **r_size)
void BKE_mesh_texspace_get_reference(Mesh *me,
char **r_texspace_flag,
float **r_texspace_location,
float **r_texspace_size)
{
BKE_mesh_texspace_ensure(me);
if (r_texflag != nullptr) {
*r_texflag = &me->texflag;
if (r_texspace_flag != nullptr) {
*r_texspace_flag = &me->texspace_flag;
}
if (r_loc != nullptr) {
*r_loc = me->loc;
if (r_texspace_location != nullptr) {
*r_texspace_location = me->texspace_location;
}
if (r_size != nullptr) {
*r_size = me->size;
if (r_texspace_size != nullptr) {
*r_texspace_size = me->texspace_size;
}
}
void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob)
{
float *texloc, *texsize;
char *texflag;
float *texspace_location, *texspace_size;
char *texspace_flag;
if (BKE_object_obdata_texspace_get(ob, &texflag, &texloc, &texsize)) {
me->texflag = *texflag;
copy_v3_v3(me->loc, texloc);
copy_v3_v3(me->size, texsize);
if (BKE_object_obdata_texspace_get(ob, &texspace_flag, &texspace_location, &texspace_size)) {
me->texspace_flag = *texspace_flag;
copy_v3_v3(me->texspace_location, texspace_location);
copy_v3_v3(me->texspace_size, texspace_size);
}
}
@ -1329,22 +1333,22 @@ float (*BKE_mesh_orco_verts_get(Object *ob))[3]
void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert)
{
float loc[3], size[3];
float texspace_location[3], texspace_size[3];
BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, size);
BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, texspace_location, texspace_size);
if (invert) {
for (int a = 0; a < totvert; a++) {
float *co = orco[a];
madd_v3_v3v3v3(co, loc, co, size);
madd_v3_v3v3v3(co, texspace_location, co, texspace_size);
}
}
else {
for (int a = 0; a < totvert; a++) {
float *co = orco[a];
co[0] = (co[0] - loc[0]) / size[0];
co[1] = (co[1] - loc[1]) / size[1];
co[2] = (co[2] - loc[2]) / size[2];
co[0] = (co[0] - texspace_location[0]) / texspace_size[0];
co[1] = (co[1] - texspace_location[1]) / texspace_size[1];
co[2] = (co[2] - texspace_location[2]) / texspace_size[2];
}
}
}
@ -1889,10 +1893,10 @@ void BKE_mesh_eval_geometry(Depsgraph *depsgraph, Mesh *mesh)
}
if (DEG_is_active(depsgraph)) {
Mesh *mesh_orig = (Mesh *)DEG_get_original_id(&mesh->id);
if (mesh->texflag & ME_AUTOSPACE_EVALUATED) {
mesh_orig->texflag |= ME_AUTOSPACE_EVALUATED;
copy_v3_v3(mesh_orig->loc, mesh->loc);
copy_v3_v3(mesh_orig->size, mesh->size);
if (mesh->texspace_flag & ME_TEXSPACE_FLAG_AUTO_EVALUATED) {
mesh_orig->texspace_flag |= ME_TEXSPACE_FLAG_AUTO_EVALUATED;
copy_v3_v3(mesh_orig->texspace_location, mesh->texspace_location);
copy_v3_v3(mesh_orig->texspace_size, mesh->texspace_size);
}
}
}

View File

@ -401,9 +401,9 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
*/
static void mesh_copy_texture_space_from_curve_type(const Curve *cu, Mesh *me)
{
me->texflag = cu->texflag & ~CU_AUTOSPACE;
copy_v3_v3(me->loc, cu->loc);
copy_v3_v3(me->size, cu->size);
me->texspace_flag = cu->texspace_flag & ~CU_TEXSPACE_FLAG_AUTO;
copy_v3_v3(me->texspace_location, cu->texspace_location);
copy_v3_v3(me->texspace_size, cu->texspace_size);
BKE_mesh_texspace_calc(me);
}

View File

@ -4360,42 +4360,45 @@ void BKE_object_sculpt_data_create(Object *ob)
ob->sculpt->mode_type = (eObjectMode)ob->mode;
}
bool BKE_object_obdata_texspace_get(Object *ob, char **r_texflag, float **r_loc, float **r_size)
bool BKE_object_obdata_texspace_get(Object *ob,
char **r_texspace_flag,
float **r_texspace_location,
float **r_texspace_size)
{
if (ob->data == nullptr) {
return false;
}
switch (GS(((ID *)ob->data)->name)) {
case ID_ME: {
BKE_mesh_texspace_get_reference((Mesh *)ob->data, r_texflag, r_loc, r_size);
BKE_mesh_texspace_get_reference(
(Mesh *)ob->data, r_texspace_flag, r_texspace_location, r_texspace_size);
break;
}
case ID_CU_LEGACY: {
Curve *cu = (Curve *)ob->data;
BKE_curve_texspace_ensure(cu);
if (r_texflag) {
*r_texflag = &cu->texflag;
if (r_texspace_flag) {
*r_texspace_flag = &cu->texspace_flag;
}
if (r_loc) {
*r_loc = cu->loc;
if (r_texspace_location) {
*r_texspace_location = cu->texspace_location;
}
if (r_size) {
*r_size = cu->size;
if (r_texspace_size) {
*r_texspace_size = cu->texspace_size;
}
break;
}
case ID_MB: {
MetaBall *mb = (MetaBall *)ob->data;
if (r_texflag) {
*r_texflag = &mb->texflag;
if (r_texspace_flag) {
*r_texspace_flag = &mb->texspace_flag;
}
if (r_loc) {
*r_loc = mb->loc;
if (r_texspace_location) {
*r_texspace_location = mb->texspace_location;
}
if (r_size) {
*r_size = mb->size;
if (r_texspace_size) {
*r_texspace_size = mb->texspace_size;
}
break;
}

View File

@ -4451,15 +4451,15 @@ void psys_get_texture(
texvec);
BKE_mesh_texspace_ensure(me);
sub_v3_v3(texvec, me->loc);
if (me->size[0] != 0.0f) {
texvec[0] /= me->size[0];
sub_v3_v3(texvec, me->texspace_location);
if (me->texspace_size[0] != 0.0f) {
texvec[0] /= me->texspace_size[0];
}
if (me->size[1] != 0.0f) {
texvec[1] /= me->size[1];
if (me->texspace_size[1] != 0.0f) {
texvec[1] /= me->texspace_size[1];
}
if (me->size[2] != 0.0f) {
texvec[2] /= me->size[2];
if (me->texspace_size[2] != 0.0f) {
texvec[2] /= me->texspace_size[2];
}
break;
case TEXCO_PARTICLE:

View File

@ -460,14 +460,14 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons
case ID_CU_LEGACY: {
Curve *cu = (Curve *)ob_data;
BKE_curve_texspace_ensure(cu);
texcoloc = cu->loc;
texcosize = cu->size;
texcoloc = cu->texspace_location;
texcosize = cu->texspace_size;
break;
}
case ID_MB: {
MetaBall *mb = (MetaBall *)ob_data;
texcoloc = mb->loc;
texcosize = mb->size;
texcoloc = mb->texspace_location;
texcosize = mb->texspace_size;
break;
}
case ID_CV:

View File

@ -627,33 +627,36 @@ void DRW_shgroup_buffer_texture_ref(DRWShadingGroup *shgroup,
static void drw_call_calc_orco(Object *ob, float (*r_orcofacs)[4])
{
ID *ob_data = (ob) ? static_cast<ID *>(ob->data) : nullptr;
float loc[3], size[3];
float *texcoloc = nullptr;
float *texcosize = nullptr;
struct {
float texspace_location[3], texspace_size[3];
} static_buf;
float *texspace_location = nullptr;
float *texspace_size = nullptr;
if (ob_data != nullptr) {
switch (GS(ob_data->name)) {
case ID_VO: {
BoundBox *bbox = BKE_volume_boundbox_get(ob);
mid_v3_v3v3(loc, bbox->vec[0], bbox->vec[6]);
sub_v3_v3v3(size, bbox->vec[0], bbox->vec[6]);
texcoloc = loc;
texcosize = size;
mid_v3_v3v3(static_buf.texspace_location, bbox->vec[0], bbox->vec[6]);
sub_v3_v3v3(static_buf.texspace_size, bbox->vec[0], bbox->vec[6]);
texspace_location = static_buf.texspace_location;
texspace_size = static_buf.texspace_size;
break;
}
case ID_ME:
BKE_mesh_texspace_get_reference((Mesh *)ob_data, nullptr, &texcoloc, &texcosize);
BKE_mesh_texspace_get_reference(
(Mesh *)ob_data, nullptr, &texspace_location, &texspace_size);
break;
case ID_CU_LEGACY: {
Curve *cu = (Curve *)ob_data;
BKE_curve_texspace_ensure(cu);
texcoloc = cu->loc;
texcosize = cu->size;
texspace_location = cu->texspace_location;
texspace_size = cu->texspace_size;
break;
}
case ID_MB: {
MetaBall *mb = (MetaBall *)ob_data;
texcoloc = mb->loc;
texcosize = mb->size;
texspace_location = mb->texspace_location;
texspace_size = mb->texspace_size;
break;
}
default:
@ -661,10 +664,10 @@ static void drw_call_calc_orco(Object *ob, float (*r_orcofacs)[4])
}
}
if ((texcoloc != nullptr) && (texcosize != nullptr)) {
mul_v3_v3fl(r_orcofacs[1], texcosize, 2.0f);
if ((texspace_location != nullptr) && (texspace_size != nullptr)) {
mul_v3_v3fl(r_orcofacs[1], texspace_size, 2.0f);
invert_v3(r_orcofacs[1]);
sub_v3_v3v3(r_orcofacs[0], texcoloc, texcosize);
sub_v3_v3v3(r_orcofacs[0], texspace_location, texspace_size);
negate_v3(r_orcofacs[0]);
mul_v3_v3(r_orcofacs[0], r_orcofacs[1]); /* result in a nice MADD in the shader */
}

View File

@ -114,14 +114,14 @@ inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active
case ID_CU_LEGACY: {
Curve &cu = *static_cast<Curve *>(ref.object->data);
BKE_curve_texspace_ensure(&cu);
orco_add = cu.loc;
orco_mul = cu.size;
orco_add = cu.texspace_location;
orco_mul = cu.texspace_size;
break;
}
case ID_MB: {
MetaBall &mb = *static_cast<MetaBall *>(ref.object->data);
orco_add = mb.loc;
orco_mul = mb.size;
orco_add = mb.texspace_location;
orco_mul = mb.texspace_size;
break;
}
default:

View File

@ -7115,7 +7115,7 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
Object *object = CTX_data_active_object(C);
Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
Curve *curve = (Curve *)object->data;
float min[3], max[3], size[3], loc[3];
float min[3], max[3], texspace_size[3], texspace_location[3];
int a;
BLI_assert(object_eval->runtime.curve_cache != NULL);
@ -7123,28 +7123,28 @@ static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
INIT_MINMAX(min, max);
BKE_displist_minmax(&object_eval->runtime.curve_cache->disp, min, max);
mid_v3_v3v3(loc, min, max);
mid_v3_v3v3(texspace_location, min, max);
size[0] = (max[0] - min[0]) / 2.0f;
size[1] = (max[1] - min[1]) / 2.0f;
size[2] = (max[2] - min[2]) / 2.0f;
texspace_size[0] = (max[0] - min[0]) / 2.0f;
texspace_size[1] = (max[1] - min[1]) / 2.0f;
texspace_size[2] = (max[2] - min[2]) / 2.0f;
for (a = 0; a < 3; a++) {
if (size[a] == 0.0f) {
size[a] = 1.0f;
if (texspace_size[a] == 0.0f) {
texspace_size[a] = 1.0f;
}
else if (size[a] > 0.0f && size[a] < 0.00001f) {
size[a] = 0.00001f;
else if (texspace_size[a] > 0.0f && texspace_size[a] < 0.00001f) {
texspace_size[a] = 0.00001f;
}
else if (size[a] < 0.0f && size[a] > -0.00001f) {
size[a] = -0.00001f;
else if (texspace_size[a] < 0.0f && texspace_size[a] > -0.00001f) {
texspace_size[a] = -0.00001f;
}
}
copy_v3_v3(curve->loc, loc);
copy_v3_v3(curve->size, size);
copy_v3_v3(curve->texspace_location, texspace_location);
copy_v3_v3(curve->texspace_size, texspace_size);
curve->texflag &= ~CU_AUTOSPACE;
curve->texspace_flag &= ~CU_TEXSPACE_FLAG_AUTO;
WM_event_add_notifier(C, NC_GEOM | ND_DATA, curve);
DEG_id_tag_update(&curve->id, ID_RECALC_GEOMETRY);

View File

@ -36,7 +36,7 @@ static void createTransTexspace(bContext *UNUSED(C), TransInfo *t)
TransData *td;
Object *ob;
ID *id;
char *texflag;
char *texspace_flag;
BKE_view_layer_synced_ensure(t->scene, t->view_layer);
ob = BKE_view_layer_active_object_get(view_layer);
@ -72,9 +72,9 @@ static void createTransTexspace(bContext *UNUSED(C), TransInfo *t)
normalize_m3(td->axismtx);
pseudoinverse_m3_m3(td->smtx, td->mtx, PSEUDOINVERSE_EPSILON);
if (BKE_object_obdata_texspace_get(ob, &texflag, &td->loc, &td->ext->size)) {
if (BKE_object_obdata_texspace_get(ob, &texspace_flag, &td->loc, &td->ext->size)) {
ob->dtx |= OB_TEXSPACE;
*texflag &= ~ME_AUTOSPACE;
*texspace_flag &= ~ME_TEXSPACE_FLAG_AUTO;
}
copy_v3_v3(td->iloc, td->loc);

View File

@ -15,7 +15,7 @@
#define _DNA_DEFAULT_Curve \
{ \
.size = {1, 1, 1}, \
.texspace_size = {1, 1, 1}, \
.flag = CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS, \
.pathlen = 100, \
.resolu = 12, \
@ -26,7 +26,7 @@
.linedist = 1.0, \
.fsize = 1.0, \
.ulheight = 0.05, \
.texflag = CU_AUTOSPACE, \
.texspace_flag = CU_TEXSPACE_FLAG_AUTO, \
.smallcaps_scale = 0.75f, \
/* This one seems to be the best one in most cases, at least for curve deform. */ \
.twist_mode = CU_TWIST_MINIMUM, \

View File

@ -211,14 +211,13 @@ typedef struct Curve {
struct CurveProfile *bevel_profile;
/* texture space, copied as one block in editobject.c */
float loc[3];
float size[3];
float texspace_location[3];
float texspace_size[3];
/** Creation-time type of curve datablock. */
short type;
char texflag;
char texspace_flag;
char _pad0[7];
short twist_mode;
float twist_smooth, smallcaps_scale;
@ -313,10 +312,10 @@ typedef struct Curve {
/* **************** CURVE ********************* */
/** #Curve.texflag */
/** #Curve.texspace_flag */
enum {
CU_AUTOSPACE = 1,
CU_AUTOSPACE_EVALUATED = 2,
CU_TEXSPACE_FLAG_AUTO = 1 << 0,
CU_TEXSPACE_FLAG_AUTO_EVALUATED = 1 << 1,
};
/** #Curve.flag */

View File

@ -15,9 +15,9 @@
#define _DNA_DEFAULT_Mesh \
{ \
.size = {1.0f, 1.0f, 1.0f}, \
.texspace_size = {1.0f, 1.0f, 1.0f}, \
.smoothresh = DEG2RADF(30), \
.texflag = ME_AUTOSPACE, \
.texspace_flag = ME_TEXSPACE_FLAG_AUTO, \
.remesh_voxel_size = 0.1f, \
.remesh_voxel_adaptivity = 0.0f, \
.face_sets_color_seed = 0, \

View File

@ -127,9 +127,9 @@ typedef struct Mesh {
struct Mesh *texcomesh;
/** Texture space location and size, used for procedural coordinates when rendering. */
float loc[3];
float size[3];
char texflag;
float texspace_location[3];
float texspace_size[3];
char texspace_flag;
/** Various flags used when editing the mesh. */
char editflag;
@ -303,10 +303,10 @@ typedef struct TFace {
/* **************** MESH ********************* */
/** #Mesh.texflag */
/** #Mesh.texspace_flag */
enum {
ME_AUTOSPACE = 1,
ME_AUTOSPACE_EVALUATED = 2,
ME_TEXSPACE_FLAG_AUTO = 1 << 0,
ME_TEXSPACE_FLAG_AUTO_EVALUATED = 1 << 1,
};
/** #Mesh.editflag */

View File

@ -15,8 +15,8 @@
#define _DNA_DEFAULT_MetaBall \
{ \
.size = {1, 1, 1}, \
.texflag = MB_AUTOSPACE, \
.texspace_size = {1, 1, 1}, \
.texspace_flag = MB_TEXSPACE_FLAG_AUTO, \
.wiresize = 0.4f, \
.rendersize = 0.2f, \
.thresh = 0.6f, \

View File

@ -65,8 +65,8 @@ typedef struct MetaBall {
/** Flag is enum for updates, flag2 is bit-flags for settings. */
char flag, flag2;
short totcol;
/** Used to store MB_AUTOSPACE. */
char texflag;
/** Used to store #MB_TEXTURE_FLAG_AUTO. */
char texspace_flag;
char _pad[2];
/**
@ -75,8 +75,8 @@ typedef struct MetaBall {
*/
char needs_flush_to_id;
float loc[3];
float size[3];
float texspace_location[3];
float texspace_size[3];
/** Display and render res. */
float wiresize, rendersize;
@ -95,8 +95,10 @@ typedef struct MetaBall {
/* **************** METABALL ********************* */
/* texflag */
#define MB_AUTOSPACE 1
/** #MetaBall.texspace_flag */
enum {
MB_TEXSPACE_FLAG_AUTO = 1 << 0,
};
/* mb->flag */
#define MB_UPDATE_ALWAYS 0

View File

@ -60,6 +60,9 @@ DNA_STRUCT_RENAME_ELEM(Collection, dupli_ofs, instance_offset)
DNA_STRUCT_RENAME_ELEM(Curve, ext1, extrude)
DNA_STRUCT_RENAME_ELEM(Curve, ext2, bevel_radius)
DNA_STRUCT_RENAME_ELEM(Curve, len_wchar, len_char32)
DNA_STRUCT_RENAME_ELEM(Curve, loc, texspace_location)
DNA_STRUCT_RENAME_ELEM(Curve, size, texspace_size)
DNA_STRUCT_RENAME_ELEM(Curve, texflag, texspace_flag)
DNA_STRUCT_RENAME_ELEM(Curve, width, offset)
DNA_STRUCT_RENAME_ELEM(CurvesGeometry, curve_size, curve_num)
DNA_STRUCT_RENAME_ELEM(CurvesGeometry, point_size, point_num)
@ -92,9 +95,15 @@ DNA_STRUCT_RENAME_ELEM(MVert, co, co_legacy)
DNA_STRUCT_RENAME_ELEM(MVert, flag, flag_legacy)
DNA_STRUCT_RENAME_ELEM(MaskLayer, restrictflag, visibility_flag)
DNA_STRUCT_RENAME_ELEM(MaterialLineArt, transparency_mask, material_mask_bits)
DNA_STRUCT_RENAME_ELEM(Mesh, loc, texspace_location)
DNA_STRUCT_RENAME_ELEM(Mesh, size, texspace_size)
DNA_STRUCT_RENAME_ELEM(Mesh, texflag, texspace_flag)
DNA_STRUCT_RENAME_ELEM(MeshDeformModifierData, totcagevert, cage_verts_num)
DNA_STRUCT_RENAME_ELEM(MeshDeformModifierData, totinfluence, influences_num)
DNA_STRUCT_RENAME_ELEM(MeshDeformModifierData, totvert, verts_num)
DNA_STRUCT_RENAME_ELEM(MetaBall, loc, texspace_location)
DNA_STRUCT_RENAME_ELEM(MetaBall, size, texspace_size)
DNA_STRUCT_RENAME_ELEM(MetaBall, texflag, texspace_flag)
DNA_STRUCT_RENAME_ELEM(MovieClip, name, filepath)
DNA_STRUCT_RENAME_ELEM(MovieTracking, act_plane_track, act_plane_track_legacy)
DNA_STRUCT_RENAME_ELEM(MovieTracking, act_track, act_track_legacy)

View File

@ -260,7 +260,7 @@ static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
{
Curve *cu = (Curve *)ptr->data;
if (cu->texflag & CU_AUTOSPACE) {
if (cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO) {
BKE_curve_texspace_calc(cu);
}
}
@ -268,23 +268,23 @@ static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), Po
static int rna_Curve_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
Curve *cu = (Curve *)ptr->data;
return (cu->texflag & CU_AUTOSPACE) ? 0 : PROP_EDITABLE;
return (cu->texspace_flag & CU_TEXSPACE_FLAG_AUTO) ? 0 : PROP_EDITABLE;
}
static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values)
static void rna_Curve_texspace_location_get(PointerRNA *ptr, float *values)
{
Curve *cu = (Curve *)ptr->data;
BKE_curve_texspace_ensure(cu);
copy_v3_v3(values, cu->loc);
copy_v3_v3(values, cu->texspace_location);
}
static void rna_Curve_texspace_loc_set(PointerRNA *ptr, const float *values)
static void rna_Curve_texspace_location_set(PointerRNA *ptr, const float *values)
{
Curve *cu = (Curve *)ptr->data;
copy_v3_v3(cu->loc, values);
copy_v3_v3(cu->texspace_location, values);
}
static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values)
@ -293,14 +293,14 @@ static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values)
BKE_curve_texspace_ensure(cu);
copy_v3_v3(values, cu->size);
copy_v3_v3(values, cu->texspace_size);
}
static void rna_Curve_texspace_size_set(PointerRNA *ptr, const float *values)
{
Curve *cu = (Curve *)ptr->data;
copy_v3_v3(cu->size, values);
copy_v3_v3(cu->texspace_size, values);
}
static void rna_Curve_material_index_range(
@ -1805,7 +1805,7 @@ static void rna_def_curve(BlenderRNA *brna)
/* texture space */
prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE);
RNA_def_property_boolean_sdna(prop, NULL, "texspace_flag", CU_TEXSPACE_FLAG_AUTO);
RNA_def_property_ui_text(
prop,
"Auto Texture Space",
@ -1818,7 +1818,7 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
RNA_def_property_float_funcs(
prop, "rna_Curve_texspace_loc_get", "rna_Curve_texspace_loc_set", NULL);
prop, "rna_Curve_texspace_location_get", "rna_Curve_texspace_location_set", NULL);
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);

View File

@ -804,7 +804,7 @@ static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values)
static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
Mesh *me = (Mesh *)ptr->data;
return (me->texflag & ME_AUTOSPACE) ? 0 : PROP_EDITABLE;
return (me->texspace_flag & ME_TEXSPACE_FLAG_AUTO) ? 0 : PROP_EDITABLE;
}
static void rna_Mesh_texspace_size_get(PointerRNA *ptr, float values[3])
@ -813,16 +813,16 @@ static void rna_Mesh_texspace_size_get(PointerRNA *ptr, float values[3])
BKE_mesh_texspace_ensure(me);
copy_v3_v3(values, me->size);
copy_v3_v3(values, me->texspace_size);
}
static void rna_Mesh_texspace_loc_get(PointerRNA *ptr, float values[3])
static void rna_Mesh_texspace_location_get(PointerRNA *ptr, float values[3])
{
Mesh *me = (Mesh *)ptr->data;
BKE_mesh_texspace_ensure(me);
copy_v3_v3(values, me->loc);
copy_v3_v3(values, me->texspace_location);
}
static void rna_MeshVertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@ -850,10 +850,10 @@ static void rna_MeshVertex_undeformed_co_get(PointerRNA *ptr, float values[3])
if (orco) {
const int index = rna_MeshVertex_index_get(ptr);
/* orco is normalized to 0..1, we do inverse to match the vertex position */
float loc[3], size[3];
float texspace_location[3], texspace_size[3];
BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, size);
madd_v3_v3v3v3(values, loc, orco[index], size);
BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, texspace_location, texspace_size);
madd_v3_v3v3v3(values, texspace_location, orco[index], texspace_size);
}
else {
copy_v3_v3(values, position);
@ -3095,21 +3095,21 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable)
/* texture space */
prop = RNA_def_property(srna, "auto_texspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", ME_AUTOSPACE);
RNA_def_property_boolean_sdna(prop, NULL, "texspace_flag", ME_TEXSPACE_FLAG_AUTO);
RNA_def_property_ui_text(
prop,
"Auto Texture Space",
"Adjust active object's texture space automatically when transforming object");
prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_float_sdna(prop, NULL, "texspace_location");
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_loc_get", NULL, NULL);
RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_location_get", NULL, NULL);
RNA_def_property_editable_func(prop, texspace_editable);
RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all");
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_float_sdna(prop, NULL, "texspace_size");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_size_get", NULL, NULL);
@ -4349,7 +4349,7 @@ static void rna_def_mesh(BlenderRNA *brna)
/* texture space */
prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", ME_AUTOSPACE);
RNA_def_property_boolean_sdna(prop, NULL, "texspace_flag", ME_TEXSPACE_FLAG_AUTO);
RNA_def_property_ui_text(
prop,
"Auto Texture Space",
@ -4362,7 +4362,7 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
RNA_def_property_editable_func(prop, "rna_Mesh_texspace_editable");
RNA_def_property_float_funcs(
prop, "rna_Mesh_texspace_loc_get", "rna_Mesh_texspace_loc_set", NULL);
prop, "rna_Mesh_texspace_location_get", "rna_Mesh_texspace_location_set", NULL);
RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
# endif

View File

@ -38,23 +38,23 @@
static int rna_Meta_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info))
{
MetaBall *mb = (MetaBall *)ptr->data;
return (mb->texflag & MB_AUTOSPACE) ? 0 : PROP_EDITABLE;
return (mb->texspace_flag & MB_TEXSPACE_FLAG_AUTO) ? 0 : PROP_EDITABLE;
}
static void rna_Meta_texspace_loc_get(PointerRNA *ptr, float *values)
static void rna_Meta_texspace_location_get(PointerRNA *ptr, float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
/* tex_space_mball() needs object.. ugh */
copy_v3_v3(values, mb->loc);
copy_v3_v3(values, mb->texspace_location);
}
static void rna_Meta_texspace_loc_set(PointerRNA *ptr, const float *values)
static void rna_Meta_texspace_location_set(PointerRNA *ptr, const float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
copy_v3_v3(mb->loc, values);
copy_v3_v3(mb->texspace_location, values);
}
static void rna_Meta_texspace_size_get(PointerRNA *ptr, float *values)
@ -63,14 +63,14 @@ static void rna_Meta_texspace_size_get(PointerRNA *ptr, float *values)
/* tex_space_mball() needs object.. ugh */
copy_v3_v3(values, mb->size);
copy_v3_v3(values, mb->texspace_size);
}
static void rna_Meta_texspace_size_set(PointerRNA *ptr, const float *values)
{
MetaBall *mb = (MetaBall *)ptr->data;
copy_v3_v3(mb->size, values);
copy_v3_v3(mb->texspace_size, values);
}
static void rna_MetaBall_redraw_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@ -358,7 +358,7 @@ static void rna_def_metaball(BlenderRNA *brna)
/* texture space */
prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", MB_AUTOSPACE);
RNA_def_property_boolean_sdna(prop, NULL, "texspace_flag", MB_TEXSPACE_FLAG_AUTO);
RNA_def_property_ui_text(
prop,
"Auto Texture Space",
@ -369,7 +369,7 @@ static void rna_def_metaball(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
RNA_def_property_editable_func(prop, "rna_Meta_texspace_editable");
RNA_def_property_float_funcs(
prop, "rna_Meta_texspace_loc_get", "rna_Meta_texspace_loc_set", NULL);
prop, "rna_Meta_texspace_location_get", "rna_Meta_texspace_location_set", NULL);
RNA_def_property_update(prop, 0, "rna_MetaBall_update_data");
prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);