25#define DNA_DEPRECATED_ALLOW
60 std::optional<Library *> owner_library,
73 &lattice_src->
key->
id,
75 reinterpret_cast<ID **
>(&lattice_dst->
key),
81 if (lattice_src->
dvert) {
197 const int totu = lt->
pntsu;
198 const int totv = lt->
pntsv;
200 return (
w * (totu * totv) + (
v * totu) + u);
205 const int totu = lt->
pntsu;
206 const int totv = lt->
pntsv;
208 *r_u = (index % totu);
209 *r_v = (index / totu) % totv;
210 *r_w = (index / (totu * totv));
214 const Lattice *lt,
const int index,
const bool flip_u,
const bool flip_v,
const bool flip_w)
221 u = (lt->
pntsu - 1) - u;
239 const bool respecthide)
245 for (
int i = 0; i < tot; i++, bp++) {
246 if ((bp->
f1 &
flag) && (!respecthide || !bp->
hide)) {
264 *r_fu = -0.5f * (res - 1);
269 *r_du = 2.0f / (res - 1);
277 float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
278 float *co, (*vert_coords)[3] =
nullptr;
286 while (u_new * v_new * w_new > 32000) {
287 if (u_new >= v_new && u_new >= w_new) {
290 else if (v_new >= u_new && v_new >= w_new) {
298 vert_coords =
static_cast<float(*)[3]
>(
299 MEM_mallocN(
sizeof(*vert_coords) * u_new * v_new * w_new,
"tmp_vcos"));
311 const float default_size = 1.0;
314 fu = -default_size / 2.0;
315 du = default_size / (u_new - 1);
319 fv = -default_size / 2.0;
320 dv = default_size / (v_new - 1);
324 fw = -default_size / 2.0;
325 dw = default_size / (w_new - 1);
330 for (
w = 0, wc = fw;
w < w_new;
w++, wc += dw) {
331 for (
v = 0, vc = fv;
v < v_new;
v++, vc += dv) {
332 for (u = 0, uc = fu; u < u_new; u++, co += 3, uc += du) {
347 if (lt_ob->
runtime->curve_cache) {
352 copy_m4_m4(mat, lt_ob->object_to_world().ptr());
355 lt_ob,
nullptr, vert_coords, u_new * v_new * w_new, 0,
nullptr, 1.0f);
406 float fac1, du = 0.0, dv = 0.0, dw = 0.0;
425 for (u = 0; u < lt->
pntsu; u++, bp++) {
426 if (u == 0 ||
v == 0 ||
w == 0 || u == lt->
pntsu - 1 ||
v == lt->
pntsv - 1 ||
440 bp->
vec[0] = (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
441 bp->
vec[1] = (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
442 bp->
vec[2] = (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
449 bp->
vec[0] += (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
450 bp->
vec[1] += (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
451 bp->
vec[2] += (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
458 bp->
vec[0] += (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
459 bp->
vec[1] += (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
460 bp->
vec[2] += (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
473 for (u = 0; u < lt->
pntsu; u++, bp++) {
484 for (
int i = 0; i < vert_len; i++) {
492 float(*vert_coords)[3] =
static_cast<float(*)[3]
>(
493 MEM_mallocN(
sizeof(*vert_coords) * vert_len, __func__));
499 const float (*vert_coords)[3],
500 const float mat[4][4])
503 for (i = 0; i < numVerts; i++) {
511 for (
int i = 0; i < vert_len; i++) {
519 if (ob->
runtime->curve_cache ==
nullptr) {
527 float(*vert_coords)[3] =
nullptr;
529 const bool is_editmode = (lt->
editlatt !=
nullptr);
532 for (; md; md = md->
next) {
551 if (vert_coords ==
nullptr) {
558 md, &mectx,
nullptr, {
reinterpret_cast<blender::float3 *
>(vert_coords), numVerts});
561 if (vert_coords ==
nullptr) {
566 if (lt_eval ==
nullptr) {
610 for (i = 0; i < numVerts; i++) {
631 for (i = 0; i < numVerts; i++) {
647 if (do_keys && lt->
key) {
649 float *fp =
static_cast<float *
>(kb->data);
650 for (i = kb->totelem; i--; fp += 3) {
664 for (i = 0; i < numVerts; i++) {
670 for (i = 0; i < numVerts; i++) {
675 if (do_keys && lt->
key) {
677 float *fp =
static_cast<float *
>(kb->data);
678 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)
struct ID * BKE_id_copy_in_lib(Main *bmain, std::optional< Library * > owner_library, const ID *id, 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_)
int BKE_lib_query_foreachid_process_flags_get(const LibraryForeachIDData *data)
@ IDWALK_DO_DEPRECATED_POINTERS
#define BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data_, id_, 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(struct ListBase *listbase) ATTR_NONNULL(1)
void unit_m4(float m[4][4])
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 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.
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
const Depsgraph * depsgraph
draw_view in_light_buf[] float
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)
void BKE_lattice_vert_coords_apply(Lattice *lt, const float(*vert_coords)[3])
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)
float(* BKE_lattice_vert_coords_alloc(const Lattice *lt, int *r_vert_len))[3]
void BKE_lattice_vert_coords_apply_with_mat4(Lattice *lt, const float(*vert_coords)[3], const float mat[4][4])
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)
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, float(*vert_coords)[3])
static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
static void clear(Message &msg)
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