Cleanup: pass a const Lattice to BKE_lattice_* functions
Also match arguments between function & declaration.
This commit is contained in:
parent
e42f03bc75
commit
9ee0912d1c
@ -26,7 +26,7 @@ struct Mesh;
|
|||||||
struct Object;
|
struct Object;
|
||||||
struct Scene;
|
struct Scene;
|
||||||
|
|
||||||
void BKE_lattice_resize(Lattice *lt, int u, int v, int w, Object *ltOb);
|
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob);
|
||||||
Lattice *BKE_lattice_add(Main *bmain, const char *name);
|
Lattice *BKE_lattice_add(Main *bmain, const char *name);
|
||||||
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
|
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du);
|
||||||
|
|
||||||
@ -50,11 +50,11 @@ void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys);
|
|||||||
|
|
||||||
bool BKE_lattice_is_any_selected(const Lattice *lt);
|
bool BKE_lattice_is_any_selected(const Lattice *lt);
|
||||||
|
|
||||||
int BKE_lattice_index_from_uvw(Lattice *lt, int u, int v, int w);
|
int BKE_lattice_index_from_uvw(const Lattice *lt, int u, int v, int w);
|
||||||
void BKE_lattice_index_to_uvw(Lattice *lt, int index, int *r_u, int *r_v, int *r_w);
|
void BKE_lattice_index_to_uvw(const Lattice *lt, int index, int *r_u, int *r_v, int *r_w);
|
||||||
int BKE_lattice_index_flip(Lattice *lt, int index, bool flip_u, bool flip_v, bool flip_w);
|
int BKE_lattice_index_flip(const Lattice *lt, int index, bool flip_u, bool flip_v, bool flip_w);
|
||||||
void BKE_lattice_bitmap_from_flag(
|
void BKE_lattice_bitmap_from_flag(
|
||||||
Lattice *lt, unsigned int *bitmap, uint8_t flag, bool clear, bool respecthide);
|
const Lattice *lt, unsigned int *bitmap, uint8_t flag, bool clear, bool respecthide);
|
||||||
|
|
||||||
/* **** Depsgraph evaluation **** */
|
/* **** Depsgraph evaluation **** */
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ IDTypeInfo IDType_ID_LT = {
|
|||||||
/*lib_override_apply_post*/ nullptr,
|
/*lib_override_apply_post*/ nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int w)
|
int BKE_lattice_index_from_uvw(const Lattice *lt, const int u, const int v, const int w)
|
||||||
{
|
{
|
||||||
const int totu = lt->pntsu;
|
const int totu = lt->pntsu;
|
||||||
const int totv = lt->pntsv;
|
const int totv = lt->pntsv;
|
||||||
@ -198,7 +198,7 @@ int BKE_lattice_index_from_uvw(Lattice *lt, const int u, const int v, const int
|
|||||||
return (w * (totu * totv) + (v * totu) + u);
|
return (w * (totu * totv) + (v * totu) + u);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_lattice_index_to_uvw(Lattice *lt, const int index, int *r_u, int *r_v, int *r_w)
|
void BKE_lattice_index_to_uvw(const Lattice *lt, const int index, int *r_u, int *r_v, int *r_w)
|
||||||
{
|
{
|
||||||
const int totu = lt->pntsu;
|
const int totu = lt->pntsu;
|
||||||
const int totv = lt->pntsv;
|
const int totv = lt->pntsv;
|
||||||
@ -209,7 +209,7 @@ void BKE_lattice_index_to_uvw(Lattice *lt, const int index, int *r_u, int *r_v,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int BKE_lattice_index_flip(
|
int BKE_lattice_index_flip(
|
||||||
Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w)
|
const Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w)
|
||||||
{
|
{
|
||||||
int u, v, w;
|
int u, v, w;
|
||||||
|
|
||||||
@ -230,8 +230,11 @@ int BKE_lattice_index_flip(
|
|||||||
return BKE_lattice_index_from_uvw(lt, u, v, w);
|
return BKE_lattice_index_from_uvw(lt, u, v, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_lattice_bitmap_from_flag(
|
void BKE_lattice_bitmap_from_flag(const Lattice *lt,
|
||||||
Lattice *lt, BLI_bitmap *bitmap, const uint8_t flag, const bool clear, const bool respecthide)
|
BLI_bitmap *bitmap,
|
||||||
|
const uint8_t flag,
|
||||||
|
const bool clear,
|
||||||
|
const bool respecthide)
|
||||||
{
|
{
|
||||||
const uint tot = lt->pntsu * lt->pntsv * lt->pntsw;
|
const uint tot = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||||
BPoint *bp;
|
BPoint *bp;
|
||||||
@ -265,7 +268,7 @@ void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
|
||||||
{
|
{
|
||||||
BPoint *bp;
|
BPoint *bp;
|
||||||
int i, u, v, w;
|
int i, u, v, w;
|
||||||
@ -278,53 +281,53 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||||||
lt->dvert = nullptr;
|
lt->dvert = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (uNew * vNew * wNew > 32000) {
|
while (u_new * v_new * w_new > 32000) {
|
||||||
if (uNew >= vNew && uNew >= wNew) {
|
if (u_new >= v_new && u_new >= w_new) {
|
||||||
uNew--;
|
u_new--;
|
||||||
}
|
}
|
||||||
else if (vNew >= uNew && vNew >= wNew) {
|
else if (v_new >= u_new && v_new >= w_new) {
|
||||||
vNew--;
|
v_new--;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wNew--;
|
w_new--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vert_coords = static_cast<float(*)[3]>(
|
vert_coords = static_cast<float(*)[3]>(
|
||||||
MEM_mallocN(sizeof(*vert_coords) * uNew * vNew * wNew, "tmp_vcos"));
|
MEM_mallocN(sizeof(*vert_coords) * u_new * v_new * w_new, "tmp_vcos"));
|
||||||
|
|
||||||
calc_lat_fudu(lt->flag, uNew, &fu, &du);
|
calc_lat_fudu(lt->flag, u_new, &fu, &du);
|
||||||
calc_lat_fudu(lt->flag, vNew, &fv, &dv);
|
calc_lat_fudu(lt->flag, v_new, &fv, &dv);
|
||||||
calc_lat_fudu(lt->flag, wNew, &fw, &dw);
|
calc_lat_fudu(lt->flag, w_new, &fw, &dw);
|
||||||
|
|
||||||
/* If old size is different than resolution changed in interface,
|
/* If old size is different than resolution changed in interface,
|
||||||
* try to do clever reinitialize of points. Pretty simply idea, we just
|
* try to do clever reinitialize of points. Pretty simply idea, we just
|
||||||
* deform new verts by old lattice, but scaling them to match old
|
* deform new verts by old lattice, but scaling them to match old
|
||||||
* size first.
|
* size first.
|
||||||
*/
|
*/
|
||||||
if (ltOb) {
|
if (lt_ob) {
|
||||||
const float default_size = 1.0;
|
const float default_size = 1.0;
|
||||||
|
|
||||||
if (uNew != 1) {
|
if (u_new != 1) {
|
||||||
fu = -default_size / 2.0;
|
fu = -default_size / 2.0;
|
||||||
du = default_size / (uNew - 1);
|
du = default_size / (u_new - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vNew != 1) {
|
if (v_new != 1) {
|
||||||
fv = -default_size / 2.0;
|
fv = -default_size / 2.0;
|
||||||
dv = default_size / (vNew - 1);
|
dv = default_size / (v_new - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wNew != 1) {
|
if (w_new != 1) {
|
||||||
fw = -default_size / 2.0;
|
fw = -default_size / 2.0;
|
||||||
dw = default_size / (wNew - 1);
|
dw = default_size / (w_new - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
co = vert_coords[0];
|
co = vert_coords[0];
|
||||||
for (w = 0, wc = fw; w < wNew; w++, wc += dw) {
|
for (w = 0, wc = fw; w < w_new; w++, wc += dw) {
|
||||||
for (v = 0, vc = fv; v < vNew; v++, vc += dv) {
|
for (v = 0, vc = fv; v < v_new; v++, vc += dv) {
|
||||||
for (u = 0, uc = fu; u < uNew; u++, co += 3, uc += du) {
|
for (u = 0, uc = fu; u < u_new; u++, co += 3, uc += du) {
|
||||||
co[0] = uc;
|
co[0] = uc;
|
||||||
co[1] = vc;
|
co[1] = vc;
|
||||||
co[2] = wc;
|
co[2] = wc;
|
||||||
@ -332,22 +335,23 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ltOb) {
|
if (lt_ob) {
|
||||||
float mat[4][4];
|
float mat[4][4];
|
||||||
int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
|
int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
|
||||||
|
|
||||||
/* works best if we force to linear type (endpoints match) */
|
/* works best if we force to linear type (endpoints match) */
|
||||||
lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
|
lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
|
||||||
|
|
||||||
if (ltOb->runtime->curve_cache) {
|
if (lt_ob->runtime->curve_cache) {
|
||||||
/* prevent using deformed locations */
|
/* prevent using deformed locations */
|
||||||
BKE_displist_free(<Ob->runtime->curve_cache->disp);
|
BKE_displist_free(<_ob->runtime->curve_cache->disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_m4_m4(mat, ltOb->object_to_world().ptr());
|
copy_m4_m4(mat, lt_ob->object_to_world().ptr());
|
||||||
unit_m4(ltOb->runtime->object_to_world.ptr());
|
unit_m4(lt_ob->runtime->object_to_world.ptr());
|
||||||
BKE_lattice_deform_coords(ltOb, nullptr, vert_coords, uNew * vNew * wNew, 0, nullptr, 1.0f);
|
BKE_lattice_deform_coords(
|
||||||
copy_m4_m4(ltOb->runtime->object_to_world.ptr(), mat);
|
lt_ob, nullptr, vert_coords, u_new * v_new * w_new, 0, nullptr, 1.0f);
|
||||||
|
copy_m4_m4(lt_ob->runtime->object_to_world.ptr(), mat);
|
||||||
|
|
||||||
lt->typeu = typeu;
|
lt->typeu = typeu;
|
||||||
lt->typev = typev;
|
lt->typev = typev;
|
||||||
@ -361,9 +365,9 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
|||||||
lt->dv = dv;
|
lt->dv = dv;
|
||||||
lt->dw = dw;
|
lt->dw = dw;
|
||||||
|
|
||||||
lt->pntsu = uNew;
|
lt->pntsu = u_new;
|
||||||
lt->pntsv = vNew;
|
lt->pntsv = v_new;
|
||||||
lt->pntsw = wNew;
|
lt->pntsw = w_new;
|
||||||
|
|
||||||
lt->actbp = LT_ACTBP_NONE;
|
lt->actbp = LT_ACTBP_NONE;
|
||||||
MEM_freeN(lt->def);
|
MEM_freeN(lt->def);
|
||||||
|
Loading…
Reference in New Issue
Block a user