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:
authorCampbell Barton <ideasman42@gmail.com>2011-06-09 19:20:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-06-09 19:20:29 +0400
commitf122a74b1e778bc902fa57f0689ac89c1dacbcef (patch)
tree7138ce2ab1fba31d94fc393534ce3bcc9aefc389 /source/blender/blenkernel
parent522f9111a56268f2155c93d562abad86c1883332 (diff)
parentd4ae38cc6c4ec8e3d13f26d12f85bca561f64f0f (diff)
svn merge -r37078:37335 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_blender.h1
-rw-r--r--source/blender/blenkernel/BKE_brush.h4
-rw-r--r--source/blender/blenkernel/BKE_deform.h4
-rw-r--r--source/blender/blenkernel/BKE_global.h1
-rw-r--r--source/blender/blenkernel/BKE_multires.h1
-rw-r--r--source/blender/blenkernel/intern/blender.c22
-rw-r--r--source/blender/blenkernel/intern/brush.c33
-rw-r--r--source/blender/blenkernel/intern/customdata.c120
-rw-r--r--source/blender/blenkernel/intern/deform.c4
-rw-r--r--source/blender/blenkernel/intern/multires.c120
-rw-r--r--source/blender/blenkernel/intern/node.c11
-rw-r--r--source/blender/blenkernel/intern/object.c73
-rw-r--r--source/blender/blenkernel/intern/particle.c6
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c9
-rw-r--r--source/blender/blenkernel/intern/sequencer.c16
15 files changed, 358 insertions, 67 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 1aeb2b5fce6..ba9036e1b05 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -89,6 +89,7 @@ extern int BKE_undo_valid(const char *name);
extern void BKE_reset_undo(void);
extern char *BKE_undo_menu_string(void);
extern void BKE_undo_number(struct bContext *C, int nr);
+extern char *BKE_undo_get_name(int nr, int *active);
void BKE_undo_save(char *fname);
extern void BKE_undo_save_quit(void);
extern struct Main *BKE_undo_get_main(struct Scene **scene);
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index ad736cd07bf..ebb9714cd1b 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -71,7 +71,7 @@ float brush_curve_strength(struct Brush *br, float p, const float len); /* used
/* sampling */
void brush_sample_tex(struct Brush *brush, float *xy, float *rgba, const int thread);
void brush_imbuf_new(struct Brush *brush, short flt, short texfalloff, int size,
- struct ImBuf **imbuf);
+ struct ImBuf **imbuf, int use_color_correction);
/* painting */
struct BrushPainter;
@@ -82,7 +82,7 @@ BrushPainter *brush_painter_new(struct Brush *brush);
void brush_painter_require_imbuf(BrushPainter *painter, short flt,
short texonly, int size);
int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos,
- double time, float pressure, void *user);
+ double time, float pressure, void *user, int use_color_correction);
void brush_painter_break_stroke(BrushPainter *painter);
void brush_painter_free(BrushPainter *painter);
diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h
index a9ac201beda..64cea929573 100644
--- a/source/blender/blenkernel/BKE_deform.h
+++ b/source/blender/blenkernel/BKE_deform.h
@@ -59,9 +59,9 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index
void defvert_copy(struct MDeformVert *dvert_r, const struct MDeformVert *dvert);
void defvert_sync(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int use_verify);
-void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, int *flip_map, int use_verify);
+void defvert_sync_mapped(struct MDeformVert *dvert_r, const struct MDeformVert *dvert, const int *flip_map, int use_verify);
void defvert_remap (struct MDeformVert *dvert, int *map);
-void defvert_flip(struct MDeformVert *dvert, int *flip_map);
+void defvert_flip(struct MDeformVert *dvert, const int *flip_map);
void defvert_normalize(struct MDeformVert *dvert);
/* utility function, note that 32 chars is the maximum string length since its only
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 0360acbea32..d21b0428d76 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -145,6 +145,7 @@ typedef struct Global {
#define G_FILE_IGNORE_DEPRECATION_WARNINGS (1 << 22) /* deprecated */
#define G_FILE_RECOVER (1 << 23)
#define G_FILE_RELATIVE_REMAP (1 << 24)
+#define G_FILE_HISTORY (1 << 25)
/* G.windowstate */
#define G_WINDOWSTATE_USERDEF 0
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index 25b56a371e7..01fcc51a441 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -99,6 +99,7 @@ void multires_topology_changed(struct Scene *scene, struct Object *ob);
void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v);
void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side, const float x, const float y, float *u, float *v);
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
+int mdisp_rot_face_to_quad_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y);
void mdisp_apply_weight(const int S, const int corners, int x, int y, const int face_side, float crn_weight[4][2], float *u_r, float *v_r);
void mdisp_flip_disp(const int S, const int corners, const float axis_x[2], const float axis_y[2], float disp[3]);
void mdisp_join_tris(struct MDisps *dst, struct MDisps *tri1, struct MDisps *tri2);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index e794d0f6172..a1822848048 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -523,7 +523,8 @@ void BKE_write_undo(bContext *C, const char *name)
static int counter= 0;
char filepath[FILE_MAXDIR+FILE_MAXFILE];
char numstr[32];
-
+ int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
+
/* calculate current filepath */
counter++;
counter= counter % U.undosteps;
@@ -531,7 +532,7 @@ void BKE_write_undo(bContext *C, const char *name)
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_make_file_string("/", filepath, btempdir, numstr);
- success= BLO_write_file(CTX_data_main(C), filepath, G.fileflags, NULL, NULL);
+ success= BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
}
@@ -619,7 +620,7 @@ void BKE_reset_undo(void)
/* based on index nr it does a restore */
void BKE_undo_number(bContext *C, int nr)
{
- curundo= BLI_findlink(&undobase, nr - 1);
+ curundo= BLI_findlink(&undobase, nr);
BKE_undo_step(C, 0);
}
@@ -645,6 +646,21 @@ int BKE_undo_valid(const char *name)
return undobase.last != undobase.first;
}
+/* get name of undo item, return null if no item with this index */
+/* if active pointer, set it to 1 if true */
+char *BKE_undo_get_name(int nr, int *active)
+{
+ UndoElem *uel= BLI_findlink(&undobase, nr);
+
+ if(active) *active= 0;
+
+ if(uel) {
+ if(active && uel==curundo)
+ *active= 1;
+ return uel->name;
+ }
+ return NULL;
+}
char *BKE_undo_menu_string(void)
{
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 25b60fef6dd..a4ceb62ab55 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -521,7 +521,7 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba, const int thread)
}
-void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf)
+void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf, int use_color_correction)
{
ImBuf *ibuf;
float xy[2], dist, rgba[4], *dstf;
@@ -529,7 +529,8 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
const int radius= brush_size(brush);
char *dst, crgb[3];
const float alpha= brush_alpha(brush);
-
+ float brush_rgb[3];
+
imbflag= (flt)? IB_rectfloat: IB_rect;
xoff = -bufsize/2.0f + 0.5f;
yoff = -bufsize/2.0f + 0.5f;
@@ -541,6 +542,11 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag);
if (flt) {
+ copy_v3_v3(brush_rgb, brush->rgb);
+ if(use_color_correction){
+ srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb);
+ }
+
for (y=0; y < ibuf->y; y++) {
dstf = ibuf->rect_float + y*rowbytes;
@@ -551,7 +557,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
if (texfall == 0) {
dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
- VECCOPY(dstf, brush->rgb);
+ VECCOPY(dstf, brush_rgb);
dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius);
}
else if (texfall == 1) {
@@ -561,10 +567,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
brush_sample_tex(brush, xy, rgba, 0);
-
- dstf[0] = rgba[0]*brush->rgb[0];
- dstf[1] = rgba[1]*brush->rgb[1];
- dstf[2] = rgba[2]*brush->rgb[2];
+ mul_v3_v3v3(dstf, rgba, brush_rgb);
dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, dist, radius);
}
}
@@ -862,7 +865,7 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float
brush_painter_do_partial(painter, NULL, x1, y2, x2, ibuf->y, 0, 0, pos);
}
-static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
+static void brush_painter_refresh_cache(BrushPainter *painter, float *pos, int use_color_correction)
{
Brush *brush= painter->brush;
BrushPainterCache *cache= &painter->cache;
@@ -889,11 +892,11 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos)
size= (cache->size)? cache->size: diameter;
if (brush->flag & BRUSH_FIXED_TEX) {
- brush_imbuf_new(brush, flt, 3, size, &cache->maskibuf);
+ brush_imbuf_new(brush, flt, 3, size, &cache->maskibuf, use_color_correction);
brush_painter_fixed_tex_partial_update(painter, pos);
}
else
- brush_imbuf_new(brush, flt, 2, size, &cache->ibuf);
+ brush_imbuf_new(brush, flt, 2, size, &cache->ibuf, use_color_correction);
cache->lastsize= diameter;
cache->lastalpha= alpha;
@@ -952,7 +955,7 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
}
}
-int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user)
+int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user, int use_color_correction)
{
Brush *brush= painter->brush;
int totpaintops= 0;
@@ -970,7 +973,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_apply_pressure(painter, brush, pressure);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, pos);
+ brush_painter_refresh_cache(painter, pos, use_color_correction);
totpaintops += func(user, painter->cache.ibuf, pos, pos);
painter->lasttime= time;
@@ -1043,7 +1046,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_jitter_pos(brush, paintpos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction);
totpaintops +=
func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos);
@@ -1057,7 +1060,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_jitter_pos(brush, pos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction);
totpaintops += func(user, painter->cache.ibuf, pos, finalpos);
@@ -1085,7 +1088,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl
brush_jitter_pos(brush, pos, finalpos);
if (painter->cache.enabled)
- brush_painter_refresh_cache(painter, finalpos);
+ brush_painter_refresh_cache(painter, finalpos, use_color_correction);
totpaintops +=
func(user, painter->cache.ibuf, painter->lastmousepos, finalpos);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 6e255438fa8..bb01de6e8d5 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -470,6 +470,7 @@ static void layerSwap_mdisps(void *data, const int *ci)
}
}
+#if 1 /* BMESH_TODO: place holder function, dont actually interp */
static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
float *UNUSED(sub_weights), int UNUSED(count), void *dest)
{
@@ -479,11 +480,128 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
if(!d->totdisp) {
d->totdisp = ((MDisps*)sources[0])->totdisp;
}
-
+
if (!d->disps && d->totdisp)
d->disps = BLI_cellalloc_calloc(sizeof(float)*3*d->totdisp, "blank mdisps in layerInterp_mdisps");
}
+#else // BMESH_TODO
+
+static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
+ float *sub_weights, int count, void *dest)
+{
+ MDisps *d = dest;
+ MDisps *s = NULL;
+ int st, stl;
+ int i, x, y;
+ int side, S, dst_corners, src_corners;
+ float crn_weight[4][2];
+ float (*sw)[4] = (void*)sub_weights;
+ float (*disps)[3], (*out)[3];
+
+ /* happens when flipping normals of newly created mesh */
+ if(!d->totdisp)
+ return;
+
+ s = sources[0];
+ dst_corners = multires_mdisp_corners(d);
+ src_corners = multires_mdisp_corners(s);
+
+ if(sub_weights && count == 2 && src_corners == 3) {
+ src_corners = multires_mdisp_corners(sources[1]);
+
+ /* special case -- converting two triangles to quad */
+ if(src_corners == 3 && dst_corners == 4) {
+ MDisps tris[2];
+ int vindex[4] = {0};
+
+ S = 0;
+ for(i = 0; i < 2; i++)
+ for(y = 0; y < 4; y++)
+ for(x = 0; x < 4; x++)
+ if(sw[x+i*4][y])
+ vindex[x] = y;
+
+ for(i = 0; i < 2; i++) {
+ float sw_m4[4][4] = {{0}};
+ int a = 7 & ~(1 << vindex[i*2] | 1 << vindex[i*2+1]);
+
+ sw_m4[0][vindex[i*2+1]] = 1;
+ sw_m4[1][vindex[i*2]] = 1;
+
+ for(x = 0; x < 3; x++)
+ if(a & (1 << x))
+ sw_m4[2][x] = 1;
+
+ tris[i] = *((MDisps*)sources[i]);
+ tris[i].disps = MEM_dupallocN(tris[i].disps);
+ layerInterp_mdisps(&sources[i], NULL, (float*)sw_m4, 1, &tris[i]);
+ }
+
+ mdisp_join_tris(d, &tris[0], &tris[1]);
+
+ for(i = 0; i < 2; i++)
+ MEM_freeN(tris[i].disps);
+
+ return;
+ }
+ }
+
+ /* For now, some restrictions on the input */
+ if(count != 1 || !sub_weights) {
+ for(i = 0; i < d->totdisp; ++i)
+ zero_v3(d->disps[i]);
+
+ return;
+ }
+
+ /* Initialize the destination */
+ disps = MEM_callocN(3*d->totdisp*sizeof(float), "iterp disps");
+
+ side = sqrt(d->totdisp / dst_corners);
+ st = (side<<1)-1;
+ stl = st - 1;
+
+ sw= (void*)sub_weights;
+ for(i = 0; i < 4; ++i) {
+ crn_weight[i][0] = 0 * sw[i][0] + stl * sw[i][1] + stl * sw[i][2] + 0 * sw[i][3];
+ crn_weight[i][1] = 0 * sw[i][0] + 0 * sw[i][1] + stl * sw[i][2] + stl * sw[i][3];
+ }
+
+ multires_mdisp_smooth_bounds(s);
+
+ out = disps;
+ for(S = 0; S < dst_corners; S++) {
+ float base[2], axis_x[2], axis_y[2];
+
+ mdisp_apply_weight(S, dst_corners, 0, 0, st, crn_weight, &base[0], &base[1]);
+ mdisp_apply_weight(S, dst_corners, side-1, 0, st, crn_weight, &axis_x[0], &axis_x[1]);
+ mdisp_apply_weight(S, dst_corners, 0, side-1, st, crn_weight, &axis_y[0], &axis_y[1]);
+
+ sub_v2_v2(axis_x, base);
+ sub_v2_v2(axis_y, base);
+ normalize_v2(axis_x);
+ normalize_v2(axis_y);
+
+ for(y = 0; y < side; ++y) {
+ for(x = 0; x < side; ++x, ++out) {
+ int crn;
+ float face_u, face_v, crn_u, crn_v;
+
+ mdisp_apply_weight(S, dst_corners, x, y, st, crn_weight, &face_u, &face_v);
+ crn = mdisp_rot_face_to_quad_crn(src_corners, st, face_u, face_v, &crn_u, &crn_v);
+
+ old_mdisps_bilinear((*out), &s->disps[crn*side*side], side, crn_u, crn_v);
+ mdisp_flip_disp(crn, dst_corners, axis_x, axis_y, *out);
+ }
+ }
+ }
+
+ MEM_freeN(d->disps);
+ d->disps = disps;
+}
+#endif // BMESH_TODO
+
static void layerCopy_mdisps(const void *source, void *dest, int count)
{
int i;
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 0c4d1d067e6..e4b4732e21a 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -122,7 +122,7 @@ void defvert_sync (MDeformVert *dvert_r, const MDeformVert *dvert, int use_verif
}
/* be sure all flip_map values are valid */
-void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, int *flip_map, int use_verify)
+void defvert_sync_mapped (MDeformVert *dvert_r, const MDeformVert *dvert, const int *flip_map, int use_verify)
{
if(dvert->totweight && dvert_r->totweight) {
int i;
@@ -171,7 +171,7 @@ void defvert_normalize (MDeformVert *dvert)
}
}
-void defvert_flip (MDeformVert *dvert, int *flip_map)
+void defvert_flip (MDeformVert *dvert, const int *flip_map)
{
MDeformWeight *dw;
int i;
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 01ef39487d6..3dfec66d2e5 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -339,7 +339,6 @@ static void multires_reallocate_mdisps(int totloop, MDisps *mdisps, int lvl)
}
}
-
static void column_vectors_to_mat3(float mat[][3], float v1[3], float v2[3], float v3[3])
{
copy_v3_v3(mat[0], v1);
@@ -444,7 +443,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
int lvl = multires_get_level(ob, mmd, 0);
int levels = mmd->totlvl - lvl;
MDisps *mdisps;
-
+
multires_set_tot_mdisps(me, mmd->totlvl);
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS);
@@ -458,7 +457,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
multires_set_tot_level(ob, mmd, lvl);
}
-DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple)
+static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple)
{
MultiresModifierData mmd= {{NULL}};
@@ -833,7 +832,6 @@ static void multiresModifier_update(DerivedMesh *dm)
ob = ccgdm->multires.ob;
me = ccgdm->multires.ob->data;
mmd = ccgdm->multires.mmd;
-
multires_set_tot_mdisps(me, mmd->totlvl);
CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop);
mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS);
@@ -1770,7 +1768,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
DMGridData **gridData, **subGridData;
Mesh *me= (Mesh*)ob->data;
MPoly *mpoly= me->mpoly;
- MLoop *mloop = me->mloop;
+ /* MLoop *mloop = me->mloop; */ /* UNUSED */
MDisps *mdisps;
int *gridOffset;
int i, /*numGrids,*/ gridSize, dGridSize, dSkip, totvert;
@@ -1895,6 +1893,60 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob)
multires_apply_smat(scene, ob, mat);
}
+/* update multires data after topology changing */
+#if 0 // BMESH_TODO
+void multires_topology_changed(Scene *scene, Object *ob)
+{
+ Mesh *me= (Mesh*)ob->data;
+ MDisps *mdisp= NULL, *cur= NULL;
+ int i, grid= 0, corners;
+ MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1);
+
+ if(mmd)
+ multires_set_tot_mdisps(me, mmd->totlvl);
+
+ CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface);
+ mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS);
+
+ if(!mdisp) return;
+
+ cur= mdisp;
+ for(i = 0; i < me->totface; i++, cur++) {
+ if(mdisp->totdisp) {
+ corners= multires_mdisp_corners(mdisp);
+ grid= mdisp->totdisp / corners;
+
+ break;
+ }
+ }
+
+ for(i = 0; i < me->totface; i++, mdisp++) {
+ int nvert= me->mface[i].v4 ? 4 : 3;
+
+ /* allocate memory for mdisp, the whole disp layer would be erased otherwise */
+ if(!mdisp->totdisp || !mdisp->disps) {
+ if(grid) {
+ mdisp->totdisp= nvert*grid;
+ mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
+ }
+
+ continue;
+ }
+
+ corners= multires_mdisp_corners(mdisp);
+
+ if(corners!=nvert) {
+ mdisp->totdisp= (mdisp->totdisp/corners)*nvert;
+
+ if(mdisp->disps)
+ MEM_freeN(mdisp->disps);
+
+ mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
+ }
+ }
+}
+#endif // BMESH_TODO
+
/* makes displacement along grid boundary symmetrical */
void multires_mdisp_smooth_bounds(MDisps *disps)
{
@@ -2114,6 +2166,7 @@ void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side,
}
}
+/* Find per-corner coordinate with given per-face UV coord */
int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
{
const float offset = face_side*0.5f - 0.5f;
@@ -2139,6 +2192,61 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u,
*y = v - offset;
}
} else {
+ int grid_size = offset;
+ float w = (face_side - 1) - u - v;
+ float W1, W2;
+
+ if (u >= v && u >= w) {S = 0; W1= w; W2= v;}
+ else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w;}
+ else {S = 2; W1 = v; W2 = u;}
+
+ W1 /= (face_side-1);
+ W2 /= (face_side-1);
+
+ *x = (1-(2*W1)/(1-W2)) * grid_size;
+ *y = (1-(2*W2)/(1-W1)) * grid_size;
+ }
+
+ return S;
+}
+
+/* Find per-corner coordinate with given per-face UV coord
+ Practically as the previous funciton but it assumes a bit different coordinate system for triangles
+ which is optimized for MDISP layer interpolation:
+
+ v
+ ^
+ | /|
+ | / |
+ | / |
+ |/______|___> u
+
+ */
+int mdisp_rot_face_to_quad_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
+{
+ const float offset = face_side*0.5f - 0.5f;
+ int S = 0;
+
+ if (corners == 4) {
+ if(u <= offset && v <= offset) S = 0;
+ else if(u > offset && v <= offset) S = 1;
+ else if(u > offset && v > offset) S = 2;
+ else if(u <= offset && v >= offset) S = 3;
+
+ if(S == 0) {
+ *y = offset - u;
+ *x = offset - v;
+ } else if(S == 1) {
+ *x = u - offset;
+ *y = offset - v;
+ } else if(S == 2) {
+ *y = u - offset;
+ *x = v - offset;
+ } else if(S == 3) {
+ *x= offset - u;
+ *y = v - offset;
+ }
+ } else {
float crn[3][4][2];
float p[2] = {u, v};
@@ -2265,7 +2373,7 @@ void mdisp_join_tris(MDisps *dst, MDisps *tri1, MDisps *tri2)
face_v = st - 1 - face_v;
} else src = tri1;
- crn = mdisp_rot_face_to_crn(3, st, face_u, face_v, &crn_u, &crn_v);
+ crn = mdisp_rot_face_to_quad_crn(3, st, face_u, face_v, &crn_u, &crn_v);
old_mdisps_bilinear((*out), &src->disps[crn*side*side], side, crn_u, crn_v);
(*out)[0] = 0;
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index ba2434bba23..3a8a2ae9c09 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -350,7 +350,7 @@ static bNodeType ntype_group;
/* groups display their internal tree name as label */
static const char *group_label(bNode *node)
{
- return node->id->name+2;
+ return (node->id)? node->id->name+2: "Missing Datablock";
}
void register_node_type_group(ListBase *lb)
@@ -2072,11 +2072,12 @@ static int set_stack_indexes_group(bNode *node, int index)
bNodeTree *ngroup= (bNodeTree*)node->id;
bNodeSocket *sock;
- if((ngroup->init & NTREE_TYPE_INIT)==0)
+ if(ngroup && (ngroup->init & NTREE_TYPE_INIT)==0)
ntreeInitTypes(ngroup);
node->stack_index = index;
- index += ntree_begin_exec_tree(ngroup);
+ if(ngroup)
+ index += ntree_begin_exec_tree(ngroup);
for (sock=node->inputs.first; sock; sock=sock->next) {
if (sock->link && sock->link->fromsock) {
@@ -2199,7 +2200,7 @@ static void composit_begin_exec(bNodeTree *ntree, bNodeStack *stack)
if(node->type==CMP_NODE_CURVE_RGB)
curvemapping_premultiply(node->storage, 0);
}
- if(node->type==NODE_GROUP)
+ if(node->type==NODE_GROUP && node->id)
composit_begin_exec((bNodeTree *)node->id, stack + node->stack_index);
}
@@ -2225,7 +2226,7 @@ static void composit_end_exec(bNodeTree *ntree, bNodeStack *stack)
if(node->type==CMP_NODE_CURVE_RGB)
curvemapping_premultiply(node->storage, 1);
- if(node->type==NODE_GROUP)
+ if(node->type==NODE_GROUP && node->id)
composit_end_exec((bNodeTree *)node->id, stack + node->stack_index);
node->need_exec= 0;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 84e54e0adaa..4b40897af18 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2400,24 +2400,42 @@ void object_set_dimensions(Object *ob, const float *value)
void minmax_object(Object *ob, float *min, float *max)
{
BoundBox bb;
- Mesh *me;
- Curve *cu;
float vec[3];
int a;
+ short change= FALSE;
switch(ob->type) {
-
case OB_CURVE:
case OB_FONT:
case OB_SURF:
- cu= ob->data;
-
- if(cu->bb==NULL) tex_space_curve(cu);
- bb= *(cu->bb);
-
- for(a=0; a<8; a++) {
- mul_m4_v3(ob->obmat, bb.vec[a]);
- DO_MINMAX(bb.vec[a], min, max);
+ {
+ Curve *cu= ob->data;
+
+ if(cu->bb==NULL) tex_space_curve(cu);
+ bb= *(cu->bb);
+
+ for(a=0; a<8; a++) {
+ mul_m4_v3(ob->obmat, bb.vec[a]);
+ DO_MINMAX(bb.vec[a], min, max);
+ }
+ change= TRUE;
+ }
+ break;
+ case OB_LATTICE:
+ {
+ Lattice *lt= ob->data;
+ BPoint *bp= lt->def;
+ int u, v, w;
+
+ for(w=0; w<lt->pntsw; w++) {
+ for(v=0; v<lt->pntsv; v++) {
+ for(u=0; u<lt->pntsu; u++, bp++) {
+ mul_v3_m4v3(vec, ob->obmat, bp->vec);
+ DO_MINMAX(vec, min, max);
+ }
+ }
+ }
+ change= TRUE;
}
break;
case OB_ARMATURE:
@@ -2429,25 +2447,27 @@ void minmax_object(Object *ob, float *min, float *max)
mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
DO_MINMAX(vec, min, max);
}
- break;
+ change= TRUE;
}
- /* no break, get_mesh will give NULL and it passes on to default */
+ break;
case OB_MESH:
- me= get_mesh(ob);
-
- if(me) {
- bb = *mesh_get_bb(ob);
-
- for(a=0; a<8; a++) {
- mul_m4_v3(ob->obmat, bb.vec[a]);
- DO_MINMAX(bb.vec[a], min, max);
+ {
+ Mesh *me= get_mesh(ob);
+
+ if(me) {
+ bb = *mesh_get_bb(ob);
+
+ for(a=0; a<8; a++) {
+ mul_m4_v3(ob->obmat, bb.vec[a]);
+ DO_MINMAX(bb.vec[a], min, max);
+ }
+ change= TRUE;
}
}
- if(min[0] < max[0] ) break;
-
- /* else here no break!!!, mesh can be zero sized */
-
- default:
+ break;
+ }
+
+ if(change == FALSE) {
DO_MINMAX(ob->obmat[3], min, max);
copy_v3_v3(vec, ob->obmat[3]);
@@ -2457,7 +2477,6 @@ void minmax_object(Object *ob, float *min, float *max)
copy_v3_v3(vec, ob->obmat[3]);
sub_v3_v3(vec, ob->size);
DO_MINMAX(vec, min, max);
- break;
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index d02661075fc..dc91f220033 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -4020,7 +4020,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *
init_particle_interpolation(sim->ob, psys, pa, &pind);
do_particle_interpolation(psys, p, pa, t, &pind, state);
- if(!keyed && !cached) {
+ if(pind.dm) {
+ mul_m4_v3(sim->ob->obmat, state->co);
+ mul_mat3_m4_v3(sim->ob->obmat, state->vel);
+ }
+ else if(!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) {
if((pa->flag & PARS_REKEY)==0) {
psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat);
mul_m4_v3(hairmat, state->co);
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index d2f05a8ca53..c19a74deff6 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -3021,10 +3021,15 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force)
/* if not already done, load / initialize data */
get_sequence_effect(seq);
- if (!(force || seq->len != v->length || !v->frameMap)) {
+ if ( (force == FALSE) &&
+ (seq->len == v->length) &&
+ (v->frameMap != NULL)
+ ) {
return;
}
- if (!seq->seq1) { /* make coverity happy and check for (CID 598)
+ if ( (seq->seq1 == NULL) ||
+ (seq->len < 1)
+ ) { /* make coverity happy and check for (CID 598)
input strip ... */
return;
}
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 009665f3a1f..b82ac69fc9e 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -587,8 +587,22 @@ void calc_sequence(Scene *scene, Sequence *seq)
if (seq->seq1) {
seq->start= seq->startdisp= MAX3(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp);
seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp);
+ /* we cant help if strips don't overlap, it wont give useful results.
+ * but at least ensure 'len' is never negative which causes bad bugs elsewhere. */
+ if(seq->enddisp < seq->startdisp) {
+ /* simple start/end swap */
+ seq->start= seq->enddisp;
+ seq->enddisp = seq->startdisp;
+ seq->startdisp= seq->start;
+ seq->flag |= SEQ_INVALID_EFFECT;
+ }
+ else {
+ seq->flag &= ~SEQ_INVALID_EFFECT;
+ }
+
seq->len= seq->enddisp - seq->startdisp;
- } else {
+ }
+ else {
calc_sequence_disp(scene, seq);
}