Lattice API: add BKE_lattice_index_flip, BKE_lattice_bitmap_from_flag
This commit is contained in:
parent
b38f645bf1
commit
5bd9730b17
@ -89,6 +89,10 @@ void BKE_lattice_translate(struct Lattice *lt, float offset[3], int do_keys);
|
||||
|
||||
int BKE_lattice_index_from_uvw(struct Lattice *lt, const int u, const int v, const int w);
|
||||
void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index, int *r_u, int *r_v, int *r_w);
|
||||
int BKE_lattice_index_flip(struct Lattice *lt, const int index,
|
||||
const bool flip_u, const bool flip_v, const bool flip_w);
|
||||
void BKE_lattice_bitmap_from_flag(struct Lattice *lt, unsigned int *bitmap, const short flag,
|
||||
const bool clear, const bool respecthide);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,9 +36,10 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_math.h"
|
||||
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
@ -63,7 +64,7 @@
|
||||
|
||||
#include "BKE_deform.h"
|
||||
|
||||
int BKE_lattice_index_from_uvw(struct Lattice *lt,
|
||||
int BKE_lattice_index_from_uvw(Lattice *lt,
|
||||
const int u, const int v, const int w)
|
||||
{
|
||||
const int totu = lt->pntsu;
|
||||
@ -72,7 +73,7 @@ int BKE_lattice_index_from_uvw(struct Lattice *lt,
|
||||
return (w * (totu * totv) + (v * totu) + u);
|
||||
}
|
||||
|
||||
void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index,
|
||||
void BKE_lattice_index_to_uvw(Lattice *lt, const int index,
|
||||
int *r_u, int *r_v, int *r_w)
|
||||
{
|
||||
const int totu = lt->pntsu;
|
||||
@ -83,6 +84,49 @@ void BKE_lattice_index_to_uvw(struct Lattice *lt, const int index,
|
||||
*r_w = (index / (totu * totv));
|
||||
}
|
||||
|
||||
int BKE_lattice_index_flip(Lattice *lt, const int index,
|
||||
const bool flip_u, const bool flip_v, const bool flip_w)
|
||||
{
|
||||
int u, v, w;
|
||||
|
||||
BKE_lattice_index_to_uvw(lt, index, &u, &v, &w);
|
||||
|
||||
if (flip_u) {
|
||||
u = (lt->pntsu - 1) - u;
|
||||
}
|
||||
|
||||
if (flip_v) {
|
||||
v = (lt->pntsv - 1) - v;
|
||||
}
|
||||
|
||||
if (flip_w) {
|
||||
w = (lt->pntsw - 1) - w;
|
||||
}
|
||||
|
||||
return BKE_lattice_index_from_uvw(lt, u, v, w);
|
||||
}
|
||||
|
||||
void BKE_lattice_bitmap_from_flag(Lattice *lt, BLI_bitmap *bitmap, const short flag,
|
||||
const bool clear, const bool respecthide)
|
||||
{
|
||||
const unsigned int tot = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
unsigned int i;
|
||||
BPoint *bp;
|
||||
|
||||
bp = lt->def;
|
||||
for (i = 0; i < tot; i++, bp++) {
|
||||
if ((bp->f1 & flag) && (!respecthide || !bp->hide)) {
|
||||
BLI_BITMAP_SET(bitmap, i);
|
||||
}
|
||||
else {
|
||||
if (clear) {
|
||||
BLI_BITMAP_CLEAR(bitmap, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
|
||||
{
|
||||
if (res == 1) {
|
||||
@ -1072,7 +1116,7 @@ struct BPoint *BKE_lattice_active_point_get(Lattice *lt)
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_lattice_center_median(struct Lattice *lt, float cent[3])
|
||||
void BKE_lattice_center_median(Lattice *lt, float cent[3])
|
||||
{
|
||||
int i, numVerts;
|
||||
|
||||
@ -1087,7 +1131,7 @@ void BKE_lattice_center_median(struct Lattice *lt, float cent[3])
|
||||
mul_v3_fl(cent, 1.0f / (float)numVerts);
|
||||
}
|
||||
|
||||
void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3])
|
||||
void BKE_lattice_minmax(Lattice *lt, float min[3], float max[3])
|
||||
{
|
||||
int i, numVerts;
|
||||
|
||||
@ -1098,7 +1142,7 @@ void BKE_lattice_minmax(struct Lattice *lt, float min[3], float max[3])
|
||||
minmax_v3v3_v3(min, max, lt->def[i].vec);
|
||||
}
|
||||
|
||||
void BKE_lattice_center_bounds(struct Lattice *lt, float cent[3])
|
||||
void BKE_lattice_center_bounds(Lattice *lt, float cent[3])
|
||||
{
|
||||
float min[3], max[3];
|
||||
|
||||
|
@ -251,18 +251,13 @@ static int lattice_select_more_less(bContext *C, const bool select)
|
||||
Lattice *lt = ((Lattice *)obedit->data)->editlatt->latt;
|
||||
BPoint *bp;
|
||||
const int tot = lt->pntsu * lt->pntsv * lt->pntsw;
|
||||
int i, w, u, v;
|
||||
int u, v, w;
|
||||
BLI_bitmap *selpoints;
|
||||
|
||||
lt->actbp = LT_ACTBP_NONE;
|
||||
|
||||
bp = lt->def;
|
||||
selpoints = BLI_BITMAP_NEW(tot, __func__);
|
||||
for (i = 0; i < tot; i++, bp++) {
|
||||
if (bp->f1 & SELECT) {
|
||||
BLI_BITMAP_SET(selpoints, i);
|
||||
}
|
||||
}
|
||||
BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false);
|
||||
|
||||
bp = lt->def;
|
||||
for (w = 0; w < lt->pntsw; w++) {
|
||||
|
Loading…
Reference in New Issue
Block a user