Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/lattice.c')
-rw-r--r--source/blender/blenkernel/intern/lattice.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index f5244ffe04c..3996a35c766 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -251,12 +251,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
MEM_freeN(vertexCos);
}
-Lattice *BKE_lattice_add(Main *bmain, const char *name)
+void BKE_lattice_init(Lattice *lt)
{
- Lattice *lt;
-
- lt = BKE_libblock_alloc(bmain, ID_LT, name);
-
+ BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(lt, id));
+
lt->flag = LT_GRID;
lt->typeu = lt->typev = lt->typew = KEY_BSPLINE;
@@ -264,7 +262,16 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
lt->actbp = LT_ACTBP_NONE;
-
+}
+
+Lattice *BKE_lattice_add(Main *bmain, const char *name)
+{
+ Lattice *lt;
+
+ lt = BKE_libblock_alloc(bmain, ID_LT, name);
+
+ BKE_lattice_init(lt);
+
return lt;
}
@@ -353,8 +360,8 @@ void BKE_lattice_make_local(Lattice *lt)
if (ob->data == lt) {
if (ob->id.lib == NULL) {
ob->data = lt_new;
- lt_new->id.us++;
- lt->id.us--;
+ id_us_plus(&lt_new->id);
+ id_us_min(&lt->id);
}
}
}
@@ -1145,8 +1152,9 @@ static void boundbox_lattice(Object *ob)
Lattice *lt;
float min[3], max[3];
- if (ob->bb == NULL)
- ob->bb = MEM_mallocN(sizeof(BoundBox), "Lattice boundbox");
+ if (ob->bb == NULL) {
+ ob->bb = MEM_callocN(sizeof(BoundBox), "Lattice boundbox");
+ }
bb = ob->bb;
lt = ob->data;
@@ -1154,6 +1162,8 @@ static void boundbox_lattice(Object *ob)
INIT_MINMAX(min, max);
BKE_lattice_minmax_dl(ob, lt, min, max);
BKE_boundbox_init_from_minmax(bb, min, max);
+
+ bb->flag &= ~BOUNDBOX_DIRTY;
}
BoundBox *BKE_lattice_boundbox_get(Object *ob)