25#define DNA_DEPRECATED_ALLOW
50 Lattice *lattice = id_cast<Lattice *>(
id);
59 std::optional<Library *> owner_library,
64 Lattice *lattice_dst = id_cast<Lattice *>(id_dst);
65 const Lattice *lattice_src = id_cast<const Lattice *>(id_src);
67 lattice_dst->
def = MEM_dupalloc(lattice_src->
def);
72 &lattice_src->
key->
id,
74 reinterpret_cast<ID **
>(&lattice_dst->
key),
85 if (lattice_src->
dvert) {
88 "Lattice MDeformVert");
98 Lattice *lattice = id_cast<Lattice *>(
id);
104 MEM_SAFE_DELETE(lattice->
def);
105 if (lattice->
dvert) {
107 lattice->
dvert =
nullptr;
113 MEM_delete(editlt->
def);
133 Lattice *lt = id_cast<Lattice *>(
id);
152 Lattice *lt = id_cast<Lattice *>(
id);
168 .id_code = Lattice::id_type,
172 .struct_size =
sizeof(
Lattice),
174 .name_plural =
N_(
"lattices"),
177 .asset_type_info =
nullptr,
182 .make_local =
nullptr,
184 .foreach_cache =
nullptr,
185 .foreach_path =
nullptr,
186 .foreach_working_space_color =
nullptr,
187 .foreach_asset_weak_reference =
nullptr,
188 .owner_pointer_get =
nullptr,
192 .blend_read_after_liblink =
nullptr,
194 .blend_read_undo_preserve =
nullptr,
196 .lib_override_apply_post =
nullptr,
201 const int totu = lt->
pntsu;
202 const int totv = lt->
pntsv;
204 return (
w * (totu * totv) + (
v * totu) + u);
209 const int totu = lt->
pntsu;
210 const int totv = lt->
pntsv;
212 *r_u = (
index % totu);
213 *r_v = (
index / totu) % totv;
214 *r_w = (
index / (totu * totv));
218 const Lattice *lt,
const int index,
const bool flip_u,
const bool flip_v,
const bool flip_w)
225 u = (lt->
pntsu - 1) - u;
243 const bool respecthide)
249 for (
int i = 0; i < tot; i++, bp++) {
250 if ((bp->
f1 & flag) && (!respecthide || !bp->
hide)) {
268 *r_fu = -0.5f * (res - 1);
273 *r_du = 2.0f / (res - 1);
281 float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0;
282 float *co, (*vert_coords)[3] =
nullptr;
290 while (u_new * v_new * w_new > 32000) {
291 if (u_new >= v_new && u_new >= w_new) {
294 else if (v_new >= u_new && v_new >= w_new) {
303 size_t(u_new) *
size_t(v_new) *
size_t(w_new),
"tmp_vcos");
315 const float default_size = 1.0;
318 fu = -default_size / 2.0;
319 du = default_size / (u_new - 1);
323 fv = -default_size / 2.0;
324 dv = default_size / (v_new - 1);
328 fw = -default_size / 2.0;
329 dw = default_size / (w_new - 1);
334 for (
w = 0, wc = fw;
w < w_new;
w++, wc += dw) {
335 for (
v = 0, vc = fv;
v < v_new;
v++, vc += dv) {
336 for (u = 0, uc = fu; u < u_new; u++, co += 3, uc += du) {
356 copy_m4_m4(mat, lt_ob->object_to_world().ptr());
359 lt_ob,
nullptr, vert_coords, u_new * v_new * w_new, 0,
nullptr, 1.0f);
389 MEM_delete(vert_coords);
419 float fac1, du = 0.0, dv = 0.0, dw = 0.0;
438 for (u = 0; u < lt->
pntsu; u++, bp++) {
439 if (u == 0 ||
v == 0 ||
w == 0 || u == lt->
pntsu - 1 ||
v == lt->
pntsv - 1 ||
453 bp->
vec[0] = (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
454 bp->
vec[1] = (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
455 bp->
vec[2] = (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
462 bp->
vec[0] += (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
463 bp->
vec[1] += (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
464 bp->
vec[2] += (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
471 bp->
vec[0] += (1.0f - fac1) * bp1->
vec[0] + fac1 * bp2->
vec[0];
472 bp->
vec[1] += (1.0f - fac1) * bp1->
vec[1] + fac1 * bp2->
vec[1];
473 bp->
vec[2] += (1.0f - fac1) * bp1->
vec[2] + fac1 * bp2->
vec[2];
486 for (u = 0; u < lt->
pntsu; u++, bp++) {
497 for (
int i = 0; i < vert_len; i++) {
498 vert_coords[i] = lt->
def[i].
vec;
515 for (i = 0; i < numVerts; i++) {
523 for (
int i = 0; i < vert_len; i++) {
539 const bool is_editmode = (lt->
editlatt !=
nullptr);
542 for (; md; md = md->
next) {
575 if (lt_eval ==
nullptr) {
618 for (i = 0; i < numVerts; i++) {
639 for (i = 0; i < numVerts; i++) {
655 if (do_keys && lt->
key) {
657 float *fp =
static_cast<float *
>(kb.
data);
658 for (i = kb.
totelem; i--; fp += 3) {
672 for (i = 0; i < numVerts; i++) {
678 for (i = 0; i < numVerts; i++) {
683 if (do_keys && lt->
key) {
685 float *fp =
static_cast<float *
>(kb.
data);
686 for (i = kb.
totelem; i--; fp += 3) {
display list (or rather multi purpose list) stuff.
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
General operations, lookup, etc. for blender objects.
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_DISABLE(_bitmap, _index)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLT_I18NCONTEXT_ID_LATTICE
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_defvert_array_free(MDeformVert *dvert, int totvert)
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_defbase_blend_write(BlendWriter *writer, const ListBaseT< bDeformGroup > *defbase)
void BKE_lattice_resize(Lattice *lt, int u_new, int v_new, int w_new, Object *lt_ob)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void BKE_defvert_array_copy(MDeformVert *dst, const MDeformVert *src, int totvert)
void BKE_lattice_params_copy(Lattice *lt_dst, const Lattice *lt_src)
void BKE_lattice_bitmap_from_flag(const Lattice *lt, unsigned int *bitmap, uint8_t flag, bool clear, bool respecthide)
void minmax_v3v3_v3(float min[3], float max[3], const float vec[3])
void BKE_displist_free(ListBaseT< DispList > *lb)
static BPoint * latt_bp(Lattice *lt, int u, int v, int w)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
void BKE_lattice_transform(Lattice *lt, const float mat[4][4], bool do_keys)
std::optional< Bounds< float3 > > BKE_lattice_minmax(const Lattice *lt)
void BKE_defvert_blend_read(BlendDataReader *reader, int count, MDeformVert *mdverts)
void BKE_defvert_blend_write(BlendWriter *writer, int count, const MDeformVert *dvlist)
Lattice * BKE_object_get_evaluated_lattice(const Object *object)
ATTR_WARN_UNUSED_RESULT const BMVert * v
MatBase< float, 4, 4 > float4x4
Array< float3 > BKE_lattice_vert_coords_alloc(const Lattice *lt)
Lattice * BKE_object_get_lattice(const Object *object)
void BKE_lattice_eval_geometry(Depsgraph *depsgraph, Lattice *latt)
void calc_lat_fudu(int flag, int res, float *r_fu, float *r_du)
void(*) BKE_lattice_batch_cache_dirty_tag_cb(Lattice *lt, int mode)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
MINLINE void mul_v3_fl(float r[3], float f)
void mul_m4_v3(const float M[4][4], float r[3])
void(*) BKE_lattice_batch_cache_free_cb(Lattice *lt)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void BKE_object_free_derived_caches(Object *ob)
void BKE_lattice_modifiers_calc(Depsgraph *depsgraph, Scene *scene, Object *ob)
BMesh const char void * data
void outside_lattice(Lattice *lt)
int BKE_lattice_index_from_uvw(const Lattice *lt, int u, int v, int w)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
MDeformVert * BKE_lattice_deform_verts_get(const Object *oblatt)
int BKE_lattice_index_flip(const Lattice *lt, int index, bool flip_u, bool flip_v, bool flip_w)
void unit_m4(float m[4][4])
BPoint * BKE_lattice_active_point_get(Lattice *lt)
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)
static void lattice_free_data(ID *id)
MINLINE void zero_v3(float r[3])
void BKE_lattice_batch_cache_free(Lattice *lt)
@ eModifierTypeFlag_AcceptsVertexCosOnly
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
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_vert_coords_apply_with_mat4(Lattice *lt, Span< float3 > vert_coordss, const float4x4 &transform)
MINLINE void add_v3_v3(float r[3], const float a[3])
void BKE_lattice_index_to_uvw(const Lattice *lt, int index, int *r_u, int *r_v, int *r_w)
bool BKE_lattice_is_any_selected(const Lattice *lt)
static void lattice_init_data(ID *id)
void BKE_lattice_batch_cache_dirty_tag(Lattice *lt, int mode)
ID_Type GS(const char *name)
void BKE_lattice_translate(Lattice *lt, const float offset[3], bool do_keys)
void BKE_defgroup_copy_list(ListBaseT< bDeformGroup > *outbase, const ListBaseT< bDeformGroup > *inbase)
void BKE_lattice_center_median(Lattice *lt, float cent[3])
void BKE_lattice_vert_coords_get(const Lattice *lt, MutableSpan< float3 > vert_coordss)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
VecBase< float, 3 > float3
void BKE_lattice_vert_coords_apply(Lattice *lt, Span< float3 > vert_coordss)
Lattice * BKE_lattice_add(Main *bmain, const char *name)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
void * BKE_id_new(Main *bmain, short type, const char *name)
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)
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void write_id_struct(const void *id_address, const T *id, BlendStructWriterTypedFn< T > fn=nullptr)
void write_struct_array(const int64_t array_size, const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
ListBaseT< DispList > disp
ListBaseT< KeyBlock > block
struct EditLatt * editlatt
draw::LatticeBatchCache * batch_cache
struct MDeformVert * dvert
ListBaseT< struct bDeformGroup > vertex_group_names
const c_style_mat & ptr() const
struct ModifierData * next
void(*) deform_verts(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh, MutableSpan< float3 > positions)
bool(*) is_disabled(const Scene *scene, ModifierData *md, bool use_render_params)
bke::ObjectRuntime * runtime