24#define DNA_DEPRECATED_ALLOW
65 std::optional<Library *> owner_library,
78 &lattice_src->
key->
id,
80 reinterpret_cast<ID **
>(&lattice_dst->
key),
86 if (lattice_src->
dvert) {
105 if (lattice->
dvert) {
107 lattice->
dvert =
nullptr;
196 const int totu = lt->
pntsu;
197 const int totv = lt->
pntsv;
199 return (
w * (totu * totv) + (
v * totu) + u);
204 const int totu = lt->
pntsu;
205 const int totv = lt->
pntsv;
207 *r_u = (index % totu);
208 *r_v = (index / totu) % totv;
209 *r_w = (index / (totu * totv));
213 const Lattice *lt,
const int index,
const bool flip_u,
const bool flip_v,
const bool flip_w)
220 u = (lt->
pntsu - 1) - u;
238 const bool respecthide)
244 for (
int i = 0;
i < tot;
i++, bp++) {
245 if ((bp->
f1 &
flag) && (!respecthide || !bp->
hide)) {
263 *r_fu = -0.5f * (res - 1);
268 *r_du = 2.0f / (res - 1);
276 float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
277 float *co, (*vert_coords)[3] =
nullptr;
285 while (u_new * v_new * w_new > 32000) {
286 if (u_new >= v_new && u_new >= w_new) {
289 else if (v_new >= u_new && v_new >= w_new) {
310 const float default_size = 1.0;
313 fu = -default_size / 2.0;
314 du = default_size / (u_new - 1);
318 fv = -default_size / 2.0;
319 dv = default_size / (v_new - 1);
323 fw = -default_size / 2.0;
324 dw = default_size / (w_new - 1);
329 for (
w = 0, wc = fw;
w < w_new;
w++, wc += dw) {
330 for (
v = 0, vc = fv;
v < v_new;
v++, vc += dv) {
331 for (u = 0, uc = fu; u < u_new; u++, co += 3, uc += du) {
346 if (lt_ob->
runtime->curve_cache) {
351 copy_m4_m4(mat, lt_ob->object_to_world().ptr());
354 lt_ob,
nullptr, vert_coords, u_new * v_new * w_new, 0,
nullptr, 1.0f);
405 float fac1, du = 0.0, dv = 0.0, dw = 0.0;
424 for (u = 0; u < lt->
pntsu; u++, bp++) {
425 if (u == 0 ||
v == 0 ||
w == 0 || u == lt->
pntsu - 1 ||
v == lt->
pntsv - 1 ||
439 bp->
vec[0] = (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
440 bp->
vec[1] = (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
441 bp->
vec[2] = (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
448 bp->
vec[0] += (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
449 bp->
vec[1] += (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
450 bp->
vec[2] += (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
457 bp->
vec[0] += (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
458 bp->
vec[1] += (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
459 bp->
vec[2] += (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
472 for (u = 0; u < lt->
pntsu; u++, bp++) {
483 for (
int i = 0;
i < vert_len;
i++) {
501 for (
i = 0;
i < numVerts;
i++) {
509 for (
int i = 0;
i < vert_len;
i++) {
517 if (ob->
runtime->curve_cache ==
nullptr) {
525 const bool is_editmode = (lt->
editlatt !=
nullptr);
528 for (; md; md = md->
next) {
561 if (lt_eval ==
nullptr) {
604 for (
i = 0;
i < numVerts;
i++) {
625 for (
i = 0;
i < numVerts;
i++) {
641 if (do_keys && lt->
key) {
643 float *fp =
static_cast<float *
>(kb->data);
644 for (
i = kb->totelem;
i--; fp += 3) {
658 for (
i = 0;
i < numVerts;
i++) {
664 for (
i = 0;
i < numVerts;
i++) {
669 if (do_keys && lt->
key) {
671 float *fp =
static_cast<float *
>(kb->data);
672 for (
i = kb->totelem;
i--; fp += 3) {
display list (or rather multi purpose list) stuff.
void BKE_displist_free(struct ListBase *lb)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void BKE_lattice_deform_coords(const Object *ob_lattice, const Object *ob_target, float(*vert_coords)[3], int vert_coords_len, short flag, const char *defgrp_name, float fac)
void(* BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode)
void(* BKE_lattice_batch_cache_free_cb)(Lattice *lt)
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, std::optional< const ID * > new_owner_id, ID **new_id_p, int flag)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
void * BKE_id_new(Main *bmain, short type, const char *name)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
@ eModifierTypeFlag_AcceptsVertexCosOnly
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
General operations, lookup, etc. for blender objects.
Lattice * BKE_object_get_lattice(const Object *object)
Lattice * BKE_object_get_evaluated_lattice(const Object *object)
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
void BKE_object_free_derived_caches(Object *ob)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_DISABLE(_bitmap, _index)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void unit_m4(float m[4][4])
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
#define BLT_I18NCONTEXT_ID_LATTICE
#define DNA_struct_default_get(struct_name)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
BPy_StructRNA * depsgraph
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void outside_lattice(Lattice *lt)
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
static void lattice_copy_data(Main *bmain, std::optional< Library * > owner_library, ID *id_dst, const ID *id_src, const int flag)
void BKE_lattice_index_to_uvw(const Lattice *lt, const int index, int *r_u, int *r_v, int *r_w)
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
std::optional< blender::Bounds< blender::float3 > > BKE_lattice_minmax(const Lattice *lt)
int BKE_lattice_index_flip(const Lattice *lt, const int index, const bool flip_u, const bool flip_v, const bool flip_w)
void(* BKE_lattice_batch_cache_dirty_tag_cb)(Lattice *lt, int mode)
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
void BKE_lattice_center_median(Lattice *lt, float cent[3])
BPoint * BKE_lattice_active_point_get(Lattice *lt)
void BKE_lattice_bitmap_from_flag(const Lattice *lt, BLI_bitmap *bitmap, const uint8_t flag, const bool clear, const bool respecthide)
static void lattice_free_data(ID *id)
int BKE_lattice_index_from_uvw(const Lattice *lt, const int u, const int v, const int w)
void(* BKE_lattice_batch_cache_free_cb)(Lattice *lt)
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
static void lattice_init_data(ID *id)
Lattice * BKE_lattice_add(Main *bmain, const char *name)
void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
bool BKE_lattice_is_any_selected(const Lattice *lt)
MDeformVert * BKE_lattice_deform_verts_get(const Object *oblatt)
static BPoint * latt_bp(Lattice *lt, int u, int v, int w)
Array< float3 > BKE_lattice_vert_coords_alloc(const Lattice *lt)
void BKE_lattice_vert_coords_apply_with_mat4(Lattice *lt, const Span< float3 > vert_coords, const float4x4 &transform)
void BKE_lattice_eval_geometry(Depsgraph *, Lattice *)
void BKE_lattice_batch_cache_free(Lattice *lt)
void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
void BKE_lattice_vert_coords_get(const Lattice *lt, MutableSpan< float3 > vert_coords)
void BKE_lattice_vert_coords_apply(Lattice *lt, const Span< float3 > vert_coords)
static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
static void clear(Message &msg)
MatBase< float, 4, 4 > float4x4
VecBase< float, 3 > float3
ListBase vertex_group_names
struct MDeformVert * dvert
struct EditLatt * editlatt
struct ModifierData * next
void(* deform_verts)(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, blender::MutableSpan< blender::float3 > positions)
bool(* is_disabled)(const Scene *scene, ModifierData *md, bool use_render_params)
ObjectRuntimeHandle * runtime