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')
-rw-r--r--source/blender/blenkernel/intern/BME_tools.c2
-rw-r--r--source/blender/blenkernel/intern/action.c7
-rw-r--r--source/blender/blenkernel/intern/anim.c32
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c11
-rw-r--r--source/blender/blenkernel/intern/armature.c8
-rw-r--r--source/blender/blenkernel/intern/blender.c64
-rw-r--r--source/blender/blenkernel/intern/boids.c6
-rw-r--r--source/blender/blenkernel/intern/brush.c101
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c4
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c45
-rw-r--r--source/blender/blenkernel/intern/colortools.c58
-rw-r--r--source/blender/blenkernel/intern/constraint.c33
-rw-r--r--source/blender/blenkernel/intern/curve.c43
-rw-r--r--source/blender/blenkernel/intern/customdata.c3
-rw-r--r--source/blender/blenkernel/intern/deform.c4
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c23
-rw-r--r--source/blender/blenkernel/intern/displist.c528
-rw-r--r--source/blender/blenkernel/intern/effect.c23
-rw-r--r--source/blender/blenkernel/intern/fcurve.c2
-rw-r--r--source/blender/blenkernel/intern/icons.c30
-rw-r--r--source/blender/blenkernel/intern/image.c9
-rw-r--r--source/blender/blenkernel/intern/key.c23
-rw-r--r--source/blender/blenkernel/intern/lattice.c2
-rw-r--r--source/blender/blenkernel/intern/material.c11
-rw-r--r--source/blender/blenkernel/intern/multires.c82
-rw-r--r--source/blender/blenkernel/intern/node.c27
-rw-r--r--source/blender/blenkernel/intern/object.c166
-rw-r--r--source/blender/blenkernel/intern/paint.c14
-rw-r--r--source/blender/blenkernel/intern/particle.c93
-rw-r--r--source/blender/blenkernel/intern/particle_system.c135
-rw-r--r--source/blender/blenkernel/intern/pointcache.c18
-rw-r--r--source/blender/blenkernel/intern/sca.c1
-rw-r--r--source/blender/blenkernel/intern/scene.c4
-rw-r--r--source/blender/blenkernel/intern/screen.c18
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c95
-rw-r--r--source/blender/blenkernel/intern/sequencer.c175
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c2
-rw-r--r--source/blender/blenkernel/intern/sketch.c2
-rw-r--r--source/blender/blenkernel/intern/smoke.c17
-rw-r--r--source/blender/blenkernel/intern/softbody.c118
-rw-r--r--source/blender/blenkernel/intern/sound.c143
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c21
-rw-r--r--source/blender/blenkernel/intern/text.c69
-rw-r--r--source/blender/blenkernel/intern/texture.c26
-rw-r--r--source/blender/blenkernel/intern/world.c30
-rw-r--r--source/blender/blenkernel/intern/writeavi.c7
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c143
-rw-r--r--source/blender/blenkernel/intern/writeframeserver.c2
48 files changed, 1148 insertions, 1332 deletions
diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c
index 7665b581d7e..99b6e7f9095 100644
--- a/source/blender/blenkernel/intern/BME_tools.c
+++ b/source/blender/blenkernel/intern/BME_tools.c
@@ -1002,7 +1002,7 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int UNUSED(defg
}
/* edge pass */
- threshold = (float)cos((angle + 0.00001) * M_PI / 180.0);
+ threshold = (float)cos((angle + 0.001) * M_PI / 180.0);
for (e=bm->edges.first; e; e=e->next) {
e->tflag1 = BME_BEVEL_ORIG;
weight = 0.0;
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 5b49d9a9841..f7086c81756 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -831,7 +831,10 @@ void pose_remove_group (Object *ob)
/* now, remove it from the pose */
BLI_freelinkN(&pose->agroups, grp);
- pose->active_group= 0;
+ pose->active_group--;
+ if(pose->active_group < 0 || pose->agroups.first == NULL) {
+ pose->active_group= 0;
+ }
}
}
@@ -1125,7 +1128,7 @@ void copy_pose_result(bPose *to, bPose *from)
/* For the calculation of the effects of an Action at the given frame on an object
* This is currently only used for the Action Constraint
*/
-void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
+void what_does_obaction (Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
{
bActionGroup *agrp= action_groups_find_named(act, groupname);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index e12ec559f4b..8aa816f9cb5 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -171,7 +171,12 @@ bMotionPath *animviz_verify_motionpaths(Scene *scene, Object *ob, bPoseChannel *
avs= &ob->avs;
dst= &ob->mpath;
}
-
+
+ /* avoid 0 size allocs */
+ if(avs->path_sf >= avs->path_ef) {
+ return NULL;
+ }
+
/* if there is already a motionpath, just return that,
* but provided it's settings are ok
*/
@@ -714,12 +719,13 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i
/* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */
if(go->ob!=ob) {
- /* Group Dupli Offset, should apply after everything else */
- if (group->dupli_ofs[0] || group->dupli_ofs[1] || group->dupli_ofs[2]) {
+ /* group dupli offset, should apply after everything else */
+ if(!is_zero_v3(group->dupli_ofs)) {
copy_m4_m4(tmat, go->ob->obmat);
sub_v3_v3v3(tmat[3], tmat[3], group->dupli_ofs);
mul_m4_m4m4(mat, tmat, ob->obmat);
- } else {
+ }
+ else {
mul_m4_m4m4(mat, go->ob->obmat, ob->obmat);
}
@@ -1206,7 +1212,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0;
float (*obmat)[4], (*oldobmat)[4];
int a, b, counter, hair = 0;
- int totpart, totchild, totgroup=0, pa_num;
+ int totpart, totchild, totgroup=0 /*, pa_num */;
int no_draw_flag = PARS_UNEXIST;
@@ -1323,7 +1329,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(pa->flag & no_draw_flag)
continue;
- pa_num = pa->num;
+ /* pa_num = pa->num; */ /* UNUSED */
pa_time = pa->time;
size = pa->size;
}
@@ -1331,7 +1337,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* handle child particle */
cpa = &psys->child[a - totpart];
- pa_num = a;
+ /* pa_num = a; */ /* UNUSED */
pa_time = psys->particles[cpa->parent].time;
size = psys_get_child_size(psys, cpa, ctime, NULL);
}
@@ -1390,7 +1396,17 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) {
for(go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) {
- mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
+
+ /* group dupli offset, should apply after everything else */
+ if(!is_zero_v3(part->dup_group->dupli_ofs)) {
+ copy_m4_m4(tmat, oblist[b]->obmat);
+ sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs);
+ mul_m4_m4m4(tmat, tmat, pamat);
+ }
+ else {
+ mul_m4_m4m4(tmat, oblist[b]->obmat, pamat);
+ }
+
mul_mat3_m4_fl(tmat, size*scale);
if(par_space_mat)
mul_m4_m4m4(mat, tmat, par_space_mat);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 5198172c205..fdc102bf779 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1043,6 +1043,9 @@ static short animsys_remap_path (AnimMapper *UNUSED(remap), char *path, char **d
}
+/* less then 1.0 evaluates to false, use epsilon to avoid float error */
+#define ANIMSYS_FLOAT_AS_BOOL(value) ((value) > ((1.0f-FLT_EPSILON)))
+
/* Write the given value to a setting using RNA, and return success */
static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_index, float value)
{
@@ -1074,9 +1077,9 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
{
case PROP_BOOLEAN:
if (array_len)
- RNA_property_boolean_set_index(&new_ptr, prop, array_index, (int)value);
+ RNA_property_boolean_set_index(&new_ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
else
- RNA_property_boolean_set(&new_ptr, prop, (int)value);
+ RNA_property_boolean_set(&new_ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
break;
case PROP_INT:
if (array_len)
@@ -1867,9 +1870,9 @@ void nladata_flush_channels (ListBase *channels)
{
case PROP_BOOLEAN:
if (RNA_property_array_length(ptr, prop))
- RNA_property_boolean_set_index(ptr, prop, array_index, (int)value);
+ RNA_property_boolean_set_index(ptr, prop, array_index, ANIMSYS_FLOAT_AS_BOOL(value));
else
- RNA_property_boolean_set(ptr, prop, (int)value);
+ RNA_property_boolean_set(ptr, prop, ANIMSYS_FLOAT_AS_BOOL(value));
break;
case PROP_INT:
if (RNA_property_array_length(ptr, prop))
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index fd25ebe266f..0b31e51d62e 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1343,8 +1343,12 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3])
cross_v3_v3v3(axis,target,nor);
/* was 0.0000000000001, caused bug [#23954], smaller values give unstable
- * roll when toggling editmode */
- if (dot_v3v3(axis,axis) > 0.00001f) {
+ * roll when toggling editmode.
+ *
+ * was 0.00001, causes bug [#27675], with 0.00000495,
+ * so a value inbetween these is needed.
+ */
+ if (dot_v3v3(axis,axis) > 0.000001f) {
/* if nor is *not* a multiple of target ... */
normalize_v3(axis);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 75c6303d800..8b4bbbd3c83 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -64,6 +64,7 @@
#include "BLI_dynstr.h"
#include "BLI_path_util.h"
#include "BLI_utildefines.h"
+#include "BLI_callbacks.h"
#include "IMB_imbuf.h"
@@ -96,7 +97,7 @@ UserDef U;
/* ListBase = {NULL, NULL}; */
short ENDIAN_ORDER;
-static char versionstr[48]= "";
+char versionstr[48]= "";
/* ********** free ********** */
@@ -110,6 +111,9 @@ void free_blender(void)
BKE_spacetypes_free(); /* after free main, it uses space callbacks */
IMB_exit();
+
+ BLI_cb_finalize();
+
seq_stripelem_cache_destruct();
free_nodesystem();
@@ -129,9 +133,9 @@ void initglobals(void)
ENDIAN_ORDER= (((char*)&ENDIAN_ORDER)[0])? L_ENDIAN: B_ENDIAN;
if(BLENDER_SUBVERSION)
- BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
+ BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
else
- BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d", BLENDER_VERSION);
+ BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d", BLENDER_VERSION);
#ifdef _WIN32 // FULLSCREEN
G.windowstate = G_WINDOWSTATE_USERDEF;
@@ -154,7 +158,6 @@ static void clear_global(void)
{
// extern short winqueue_break; /* screen.c */
- fastshade_free_render(); /* lamps hang otherwise */
free_main(G.main); /* free all lib data */
// free_vertexpaint();
@@ -180,7 +183,6 @@ static void clean_paths(Main *main)
BLI_bpathIterator_free(bpi);
for(scene= main->scene.first; scene; scene= scene->id.next) {
- BLI_clean(scene->r.backbuf);
BLI_clean(scene->r.pic);
}
}
@@ -191,7 +193,7 @@ static void clean_paths(Main *main)
/* note, this is called on Undo so any slow conversion functions here
* should be avoided or check (mode!='u') */
-static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename)
+static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath)
{
bScreen *curscreen= NULL;
Scene *curscene= NULL;
@@ -295,18 +297,18 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename
if(recover && bfd->filename[0] && G.relbase_valid) {
/* in case of autosave or quit.blend, use original filename instead
* use relbase_valid to make sure the file is saved, else we get <memory2> in the filename */
- filename= bfd->filename;
+ filepath= bfd->filename;
}
#if 0
else if (!G.relbase_valid) {
/* otherwise, use an empty string as filename, rather than <memory2> */
- filename="";
+ filepath="";
}
#endif
/* these are the same at times, should never copy to the same location */
- if(G.main->name != filename)
- BLI_strncpy(G.main->name, filename, FILE_MAX);
+ if(G.main->name != filepath)
+ BLI_strncpy(G.main->name, filepath, FILE_MAX);
/* baseflags, groups, make depsgraph, etc */
set_scene_bg(G.main, CTX_data_scene(C));
@@ -353,15 +355,15 @@ void BKE_userdef_free(void)
BLI_freelistN(&U.addons);
}
-int BKE_read_file(bContext *C, const char *dir, ReportList *reports)
+int BKE_read_file(bContext *C, const char *filepath, ReportList *reports)
{
BlendFileData *bfd;
int retval= BKE_READ_FILE_OK;
- if(strstr(dir, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
- printf("read blend: %s\n", dir);
+ if(strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
+ printf("read blend: %s\n", filepath);
- bfd= BLO_read_from_file(dir, reports);
+ bfd= BLO_read_from_file(filepath, reports);
if (bfd) {
if(bfd->user) retval= BKE_READ_FILE_OK_USERPREFS;
@@ -372,10 +374,10 @@ int BKE_read_file(bContext *C, const char *dir, ReportList *reports)
retval= BKE_READ_FILE_FAIL;
}
else
- setup_app_data(C, bfd, dir); // frees BFD
+ setup_app_data(C, bfd, filepath); // frees BFD
}
else
- BKE_reports_prependf(reports, "Loading %s failed: ", dir);
+ BKE_reports_prependf(reports, "Loading %s failed: ", filepath);
return (bfd?retval:BKE_READ_FILE_FAIL);
}
@@ -521,19 +523,20 @@ void BKE_write_undo(bContext *C, const char *name)
/* disk save version */
if(UNDO_DISK) {
static int counter= 0;
- char tstr[FILE_MAXDIR+FILE_MAXFILE];
+ char filepath[FILE_MAXDIR+FILE_MAXFILE];
char numstr[32];
-
- /* calculate current filename */
+ int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */
+
+ /* calculate current filepath */
counter++;
counter= counter % U.undosteps;
BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
- BLI_make_file_string("/", tstr, btempdir, numstr);
+ BLI_make_file_string("/", filepath, btempdir, numstr);
- success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL);
+ success= BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL);
- BLI_strncpy(curundo->str, tstr, sizeof(curundo->str));
+ BLI_strncpy(curundo->str, filepath, sizeof(curundo->str));
}
else {
MemFile *prevfile=NULL;
@@ -619,7 +622,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 +648,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/boids.c b/source/blender/blenkernel/intern/boids.c
index 9f808704eee..a0f38e675f9 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -937,6 +937,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
BoidValues val;
BoidState *state = get_boid_state(boids, pa);
BoidParticle *bpa = pa->boid;
+ ParticleSystem *psys = bbd->sim->psys;
int rand;
//BoidCondition *cond;
@@ -959,9 +960,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f;
/* create random seed for every particle & frame */
- BLI_srandom(bbd->sim->psys->seed + p);
- rand = BLI_rand();
- BLI_srandom((int)bbd->cfra + rand);
+ rand = (int)(PSYS_FRAND(psys->seed + p) * 1000);
+ rand = (int)(PSYS_FRAND((int)bbd->cfra + rand) * 1000);
set_boid_values(&val, bbd->part->boids, pa);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index fa3b756ae27..c497cd2813a 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -235,8 +235,6 @@ void make_local_brush(Brush *brush)
if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) {
if(scene->id.lib==NULL) {
paint_brush_set(&scene->toolsettings->imapaint.paint, brushn);
- brushn->id.us++;
- brush->id.us--;
}
}
}
@@ -426,13 +424,6 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset)
curvemapping_changed(b->curve, 0);
}
-static MTex *brush_active_texture(Brush *brush)
-{
- if(brush)
- return &brush->mtex;
- return NULL;
-}
-
int brush_texture_set_nr(Brush *brush, int nr)
{
ID *idtest, *id=NULL;
@@ -528,7 +519,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;
@@ -536,7 +527,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;
@@ -548,6 +540,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;
@@ -558,7 +555,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) {
@@ -568,10 +565,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);
}
}
@@ -869,7 +863,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;
@@ -896,11 +890,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;
@@ -959,7 +953,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;
@@ -977,7 +971,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;
@@ -1050,7 +1044,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);
@@ -1064,7 +1058,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);
@@ -1092,7 +1086,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);
@@ -1185,7 +1179,7 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side)
}
/**** Radial Control ****/
-static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
+struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
{
ImBuf *im = MEM_callocN(sizeof(ImBuf), "radial control texture");
unsigned int *texcache;
@@ -1219,50 +1213,6 @@ static struct ImBuf *brush_gen_radial_control_imbuf(Brush *br)
return im;
}
-void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight)
-{
- int mode = RNA_enum_get(op->ptr, "mode");
- float original_value= 0;
-
- if(mode == WM_RADIALCONTROL_SIZE)
- original_value = brush_size(br) * size_weight;
- else if(mode == WM_RADIALCONTROL_STRENGTH)
- original_value = brush_alpha(br);
- else if(mode == WM_RADIALCONTROL_ANGLE) {
- MTex *mtex = brush_active_texture(br);
- if(mtex)
- original_value = mtex->rot;
- }
-
- RNA_float_set(op->ptr, "initial_value", original_value);
- op->customdata = brush_gen_radial_control_imbuf(br);
-}
-
-int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight)
-{
- int mode = RNA_enum_get(op->ptr, "mode");
- float new_value = RNA_float_get(op->ptr, "new_value");
- const float conv = 0.017453293;
-
- if(mode == WM_RADIALCONTROL_SIZE)
- if (brush_use_locked_size(br)) {
- float initial_value = RNA_float_get(op->ptr, "initial_value");
- const float unprojected_radius = brush_unprojected_radius(br);
- brush_set_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight);
- }
- else
- brush_set_size(br, new_value * size_weight);
- else if(mode == WM_RADIALCONTROL_STRENGTH)
- brush_set_alpha(br, new_value);
- else if(mode == WM_RADIALCONTROL_ANGLE) {
- MTex *mtex = brush_active_texture(br);
- if(mtex)
- mtex->rot = new_value * conv;
- }
-
- return OPERATOR_FINISHED;
-}
-
/* Unified Size and Strength */
static void set_unified_settings(Brush *brush, short flag, int value)
@@ -1302,6 +1252,19 @@ static short unified_settings(Brush *brush)
return 0;
}
+// XXX: be careful about setting size and unprojected radius
+// because they depend on one another
+// these functions do not set the other corresponding value
+// this can lead to odd behavior if size and unprojected
+// radius become inconsistent.
+// the biggest problem is that it isn't possible to change
+// unprojected radius because a view context is not
+// available. my ussual solution to this is to use the
+// ratio of change of the size to change the unprojected
+// radius. Not completely convinced that is correct.
+// In anycase, a better solution is needed to prevent
+// inconsistency.
+
static void set_unified_size(Brush *brush, int value)
{
Scene *sce;
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 5520e4d1d41..c3aeb440938 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -493,7 +493,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co,
// NOTE: casts to "float*" here are due to co being "const float*"
closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1);
- dist = len_v3v3(nearest_tmp, (float*)co);
+ dist = len_squared_v3v3(nearest_tmp, (float*)co);
if(dist < nearest->dist)
{
@@ -719,7 +719,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
if(!data->cached)
BLI_bvhtree_free(data->tree);
- memset( data, 0, sizeof(data) );
+ memset( data, 0, sizeof(*data) );
}
}
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 72ee9b55800..662c872b7f1 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -284,8 +284,10 @@ static void cdDM_drawVerts(DerivedMesh *dm)
else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */
GPU_vertex_setup(dm);
if( !GPU_buffer_legacy(dm) ) {
- if(dm->drawObject->nelements) glDrawArrays(GL_POINTS,0, dm->drawObject->nelements);
- else glDrawArrays(GL_POINTS,0, dm->drawObject->nlooseverts);
+ if(dm->drawObject->tot_triangle_point)
+ glDrawArrays(GL_POINTS,0, dm->drawObject->tot_triangle_point);
+ else
+ glDrawArrays(GL_POINTS,0, dm->drawObject->tot_loose_point);
}
GPU_buffer_unbind();
}
@@ -547,9 +549,10 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm,
GPU_normal_setup( dm );
if( !GPU_buffer_legacy(dm) ) {
glShadeModel(GL_SMOOTH);
- for( a = 0; a < dm->drawObject->nmaterials; a++ ) {
+ for( a = 0; a < dm->drawObject->totmaterial; a++ ) {
if( setMaterial(dm->drawObject->materials[a].mat_nr+1, NULL) )
- glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start, dm->drawObject->materials[a].end-dm->drawObject->materials[a].start);
+ glDrawArrays(GL_TRIANGLES, dm->drawObject->materials[a].start,
+ dm->drawObject->materials[a].totpoint);
}
}
GPU_buffer_unbind( );
@@ -629,13 +632,13 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha
GPU_color_setup(dm);
if( !GPU_buffer_legacy(dm) ) {
glShadeModel(GL_SMOOTH);
- glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->nelements);
+ glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->tot_triangle_point);
if( useTwoSided ) {
GPU_color4_upload(dm,cp2);
GPU_color_setup(dm);
glCullFace(GL_FRONT);
- glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->nelements);
+ glDrawArrays(GL_TRIANGLES, 0, dm->drawObject->tot_triangle_point);
glCullFace(GL_BACK);
}
}
@@ -787,8 +790,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
glShadeModel( GL_SMOOTH );
lastFlag = 0;
- for(i = 0; i < dm->drawObject->nelements/3; i++) {
- int actualFace = dm->drawObject->faceRemap[i];
+ for(i = 0; i < dm->drawObject->tot_triangle_point/3; i++) {
+ int actualFace = dm->drawObject->triangle_to_mface[i];
int flag = 1;
if(drawParams) {
@@ -819,13 +822,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
startFace = i;
}
}
- if( startFace < dm->drawObject->nelements/3 ) {
+ if( startFace < dm->drawObject->tot_triangle_point/3 ) {
if( lastFlag != 0 ) { /* if the flag is 0 it means the face is hidden or invisible */
if (lastFlag==1 && col)
GPU_color_switch(1);
else
GPU_color_switch(0);
- glDrawArrays(GL_TRIANGLES,startFace*3,dm->drawObject->nelements-startFace*3);
+ glDrawArrays(GL_TRIANGLES, startFace*3, dm->drawObject->tot_triangle_point - startFace*3);
}
}
}
@@ -935,7 +938,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
if( useColors && mc )
GPU_color_setup(dm);
if( !GPU_buffer_legacy(dm) ) {
- int tottri = dm->drawObject->nelements/3;
+ int tottri = dm->drawObject->tot_triangle_point/3;
glShadeModel(GL_SMOOTH);
if(tottri == 0) {
@@ -947,17 +950,17 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
}
else {
/* we need to check if the next material changes */
- int next_actualFace= dm->drawObject->faceRemap[0];
+ int next_actualFace= dm->drawObject->triangle_to_mface[0];
for( i = 0; i < tottri; i++ ) {
- //int actualFace = dm->drawObject->faceRemap[i];
+ //int actualFace = dm->drawObject->triangle_to_mface[i];
int actualFace = next_actualFace;
MFace *mface= mf + actualFace;
int drawSmooth= (mface->flag & ME_SMOOTH);
int draw = 1;
if(i != tottri-1)
- next_actualFace= dm->drawObject->faceRemap[i+1];
+ next_actualFace= dm->drawObject->triangle_to_mface[i+1];
orig= (index==NULL) ? actualFace : index[actualFace];
@@ -1129,9 +1132,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
GPU_normal_setup(dm);
if( !GPU_buffer_legacy(dm) ) {
- for( i = 0; i < dm->drawObject->nelements/3; i++ ) {
+ for( i = 0; i < dm->drawObject->tot_triangle_point/3; i++ ) {
- a = dm->drawObject->faceRemap[i];
+ a = dm->drawObject->triangle_to_mface[i];
mface = mf + a;
new_matnr = mface->mat_nr + 1;
@@ -1153,7 +1156,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
if( numdata != 0 ) {
- GPU_buffer_free(buffer, NULL);
+ GPU_buffer_free(buffer);
buffer = NULL;
}
@@ -1193,7 +1196,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
}
if( numdata != 0 ) {
elementsize = GPU_attrib_element_size( datatypes, numdata );
- buffer = GPU_buffer_alloc( elementsize*dm->drawObject->nelements, NULL );
+ buffer = GPU_buffer_alloc( elementsize*dm->drawObject->tot_triangle_point);
if( buffer == NULL ) {
GPU_buffer_unbind();
dm->drawObject->legacy = 1;
@@ -1202,7 +1205,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
varray = GPU_buffer_lock_stream(buffer);
if( varray == NULL ) {
GPU_buffer_unbind();
- GPU_buffer_free(buffer, NULL);
+ GPU_buffer_free(buffer);
dm->drawObject->legacy = 1;
return;
}
@@ -1284,6 +1287,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang);
offset += sizeof(float)*4;
}
+ (void)offset;
}
curface++;
if(mface->v4) {
@@ -1324,6 +1328,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang);
offset += sizeof(float)*4;
}
+ (void)offset;
}
curface++;
i++;
@@ -1341,7 +1346,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
}
GPU_buffer_unbind();
}
- GPU_buffer_free( buffer, NULL );
+ GPU_buffer_free(buffer);
}
glShadeModel(GL_FLAT);
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 1d7481b365a..9a6c2cc7e31 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -37,10 +37,6 @@
#include <stdlib.h>
#include <float.h>
-#ifdef WITH_LCMS
-#include <lcms.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "DNA_color_types.h"
@@ -789,60 +785,6 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const
}
-#ifdef WITH_LCMS
-/* basic error handler, if we dont do this blender will exit */
-static int ErrorReportingFunction(int ErrorCode, const char *ErrorText)
-{
- fprintf(stderr, "%s:%d\n", ErrorText, ErrorCode);
- return 1;
-}
-#endif
-
-void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile)
-{
-#ifdef WITH_LCMS
- if (ibuf->crect == NULL)
- {
- cmsHPROFILE proofingProfile;
-
- /* TODO, move to initialization area of code */
- //cmsSetLogErrorHandler(ErrorReportingFunction);
- cmsSetErrorHandler(ErrorReportingFunction);
-
- /* will return NULL if the file isn't fount */
- proofingProfile = cmsOpenProfileFromFile(profile, "r");
-
- cmsErrorAction(LCMS_ERROR_SHOW);
-
- if(proofingProfile) {
- cmsHPROFILE imageProfile;
- cmsHTRANSFORM hTransform;
-
- ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect");
-
- imageProfile = cmsCreate_sRGBProfile();
-
-
- hTransform = cmsCreateProofingTransform(imageProfile, TYPE_RGBA_8, imageProfile, TYPE_RGBA_8,
- proofingProfile,
- INTENT_ABSOLUTE_COLORIMETRIC,
- INTENT_ABSOLUTE_COLORIMETRIC,
- cmsFLAGS_SOFTPROOFING);
-
- cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y);
-
- cmsDeleteTransform(hTransform);
- cmsCloseProfile(imageProfile);
- cmsCloseProfile(proofingProfile);
- }
- }
-#else
- /* unused */
- (void)ibuf;
- (void)profile;
-#endif
-}
-
/* only used for image editor curves */
void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf)
{
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index d3c14a9dd12..7be4744a224 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -424,7 +424,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
/* ------------ General Target Matrix Tools ---------- */
/* function that sets the given matrix based on given vertex group in mesh */
-static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4])
+static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4])
{
DerivedMesh *dm = NULL;
Mesh *me= ob->data;
@@ -449,16 +449,9 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substr
freeDM= 1;
}
else {
- /* when not in EditMode, use the 'final' derived mesh
- * - check if the custom data masks for derivedFinal mean that we can just use that
- * (this is more effficient + sufficient for most cases)
- */
- if (!(ob->lastDataMask & CD_MASK_MDEFORMVERT)) {
- dm = mesh_get_derived_final(scene, ob, CD_MASK_MDEFORMVERT);
- freeDM= 1;
- }
- else
- dm = (DerivedMesh *)ob->derivedFinal;
+ /* when not in EditMode, use the 'final' derived mesh, depsgraph
+ * ensures we build with CD_MDEFORMVERT layer */
+ dm = (DerivedMesh *)ob->derivedFinal;
}
/* only continue if there's a valid DerivedMesh */
@@ -587,7 +580,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float
/* generic function to get the appropriate matrix for most target cases */
/* The cases where the target can be object data have not been implemented */
-static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
+static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
{
/* Case OBJECT */
if (!strlen(substring)) {
@@ -604,7 +597,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *sub
* way as constraints can only really affect things on object/bone level.
*/
else if (ob->type == OB_MESH) {
- contarget_get_mesh_mat(scene, ob, substring, mat);
+ contarget_get_mesh_mat(ob, substring, mat);
constraint_mat_convertspace(ob, NULL, mat, from, to);
}
else if (ob->type == OB_LATTICE) {
@@ -684,10 +677,10 @@ static bConstraintTypeInfo CTI_CONSTRNAME = {
/* This function should be used for the get_target_matrix member of all
* constraints that are not picky about what happens to their target matrix.
*/
-static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime))
+static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime))
{
if (VALID_CONS_TARGET(ct))
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
else if (ct)
unit_m4(ct->matrix);
}
@@ -1159,7 +1152,7 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra
bKinematicConstraint *data= con->data;
if (VALID_CONS_TARGET(ct))
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
else if (ct) {
if (data->flag & CONSTRAINT_IK_AUTO) {
Object *ob= cob->ob;
@@ -2046,7 +2039,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT
/* firstly calculate the matrix the normal way, then let the py-function override
* this matrix if it needs to do so
*/
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
/* only execute target calculation if allowed */
#ifdef WITH_PYTHON
@@ -2165,7 +2158,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
unit_m4(ct->matrix);
/* get the transform matrix of the target */
- constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
+ constraint_target_to_mat4(ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail);
/* determine where in transform range target is */
/* data->type is mapped as follows for backwards compatability:
@@ -2216,7 +2209,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
tchan->rotmode= pchan->rotmode;
/* evaluate action using workob (it will only set the PoseChannel in question) */
- what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t);
+ what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t);
/* convert animation to matrices for use here */
pchan_calc_mat(tchan);
@@ -2230,7 +2223,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint
/* evaluate using workob */
// FIXME: we don't have any consistent standards on limiting effects on object...
- what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, NULL, t);
+ what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t);
object_to_mat4(&workob, ct->matrix);
}
else {
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index b104c6c9b30..202a3f28d9a 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1859,7 +1859,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
* do this by calculating the tilt angle difference, then apply
* the rotation gradually over the entire curve
*
- * note that the split is between last and second last, rather then first/last as youd expect.
+ * note that the split is between last and second last, rather than first/last as youd expect.
*
* real order is like this
* 0,1,2,3,4 --> 1,2,3,4,0
@@ -2431,6 +2431,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
{
float *p1,*p2,*p3, pt[3];
float dx1,dy1,dz1,dx,dy,dz,vx,vy,vz,len,len1,len2;
+ const float eps= 1e-5;
if(bezt->h1==0 && bezt->h2==0) return;
@@ -2587,30 +2588,38 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
if(bezt->f1 & SELECT) { /* order of calculation */
if(bezt->h2==HD_ALIGN) { /* aligned */
- len= len2/len1;
- p2[3]= p2[0]+len*(p2[0]-p2[-3]);
- p2[4]= p2[1]+len*(p2[1]-p2[-2]);
- p2[5]= p2[2]+len*(p2[2]-p2[-1]);
+ if(len1>eps) {
+ len= len2/len1;
+ p2[3]= p2[0]+len*(p2[0]-p2[-3]);
+ p2[4]= p2[1]+len*(p2[1]-p2[-2]);
+ p2[5]= p2[2]+len*(p2[2]-p2[-1]);
+ }
}
if(bezt->h1==HD_ALIGN) {
- len= len1/len2;
- p2[-3]= p2[0]+len*(p2[0]-p2[3]);
- p2[-2]= p2[1]+len*(p2[1]-p2[4]);
- p2[-1]= p2[2]+len*(p2[2]-p2[5]);
+ if(len2>eps) {
+ len= len1/len2;
+ p2[-3]= p2[0]+len*(p2[0]-p2[3]);
+ p2[-2]= p2[1]+len*(p2[1]-p2[4]);
+ p2[-1]= p2[2]+len*(p2[2]-p2[5]);
+ }
}
}
else {
if(bezt->h1==HD_ALIGN) {
- len= len1/len2;
- p2[-3]= p2[0]+len*(p2[0]-p2[3]);
- p2[-2]= p2[1]+len*(p2[1]-p2[4]);
- p2[-1]= p2[2]+len*(p2[2]-p2[5]);
+ if(len2>eps) {
+ len= len1/len2;
+ p2[-3]= p2[0]+len*(p2[0]-p2[3]);
+ p2[-2]= p2[1]+len*(p2[1]-p2[4]);
+ p2[-1]= p2[2]+len*(p2[2]-p2[5]);
+ }
}
if(bezt->h2==HD_ALIGN) { /* aligned */
- len= len2/len1;
- p2[3]= p2[0]+len*(p2[0]-p2[-3]);
- p2[4]= p2[1]+len*(p2[1]-p2[-2]);
- p2[5]= p2[2]+len*(p2[2]-p2[-1]);
+ if(len1>eps) {
+ len= len2/len1;
+ p2[3]= p2[0]+len*(p2[0]-p2[-3]);
+ p2[4]= p2[1]+len*(p2[1]-p2[-2]);
+ p2[5]= p2[2]+len*(p2[2]-p2[-1]);
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index f5f069767eb..8d19322c0db 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -466,7 +466,6 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
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++)
@@ -540,7 +539,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
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_crn(src_corners, st, face_u, face_v, &crn_u, &crn_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);
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 0696653d2e4..11a0a5884ee 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -121,7 +121,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;
@@ -170,7 +170,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/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 6813d5d18a6..d39be9d683c 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -372,6 +372,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
node2->first_ancestor = ob;
node2->ancestor_count += 1;
}
+
+ /* also build a custom data mask for dependencies that need certain layers */
+ node->customdata_mask= 0;
if (ob->type == OB_ARMATURE) {
if (ob->pose){
@@ -451,8 +454,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
case PARSKEL:
dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent");
break;
- case PARVERT1: case PARVERT3: case PARBONE:
+ case PARVERT1: case PARVERT3:
dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent");
+ node2->customdata_mask |= CD_MASK_ORIGINDEX;
+ break;
+ case PARBONE:
+ dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent");
break;
default:
if(ob->parent->type==OB_LATTICE)
@@ -592,7 +599,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if(part->ren_as == PART_DRAW_GR && part->dup_group) {
for(go=part->dup_group->gobject.first; go; go=go->next) {
node2 = dag_get_node(dag, go->ob);
- dag_add_relation(dag, node, node2, DAG_RL_OB_OB, "Particle Group Visualisation");
+ dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation");
}
}
@@ -647,8 +654,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO))
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
else {
- if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0]))
+ if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) {
dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
+ if (obt->type == OB_MESH)
+ node2->customdata_mask |= CD_MASK_MDEFORMVERT;
+ }
else
dag_add_relation(dag, node2, node, DAG_RL_OB_OB, cti->name);
}
@@ -722,6 +732,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask)
itA->node->color |= itA->type;
}
}
+
+ /* also flush custom data mask */
+ ((Object*)node->ob)->customdata_mask= node->customdata_mask;
}
}
/* now set relations equal, so that when only one parent changes, the correct recalcs are found */
@@ -1189,7 +1202,7 @@ DagNodeQueue * graph_dfs(void)
int skip = 0;
int minheight;
int maxpos=0;
- int is_cycle = 0;
+ /* int is_cycle = 0; */ /* UNUSED */
/*
*fprintf(stderr,"starting DFS \n ------------\n");
*/
@@ -1245,7 +1258,7 @@ DagNodeQueue * graph_dfs(void)
} else {
if (itA->node->color == DAG_GRAY) { // back edge
fprintf(stderr,"dfs back edge :%15s %15s \n",((ID *) node->ob)->name, ((ID *) itA->node->ob)->name);
- is_cycle = 1;
+ /* is_cycle = 1; */ /* UNUSED */
} else if (itA->node->color == DAG_BLACK) {
;
/* already processed node but we may want later to change distance either to shorter to longer.
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index b5194ca2f89..8f57490d057 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -65,13 +65,12 @@
#include "BKE_lattice.h"
#include "BKE_modifier.h"
-#include "RE_pipeline.h"
-#include "RE_shader_ext.h"
-
#include "BLO_sys_types.h" // for intptr_t support
#include "ED_curve.h" /* for BKE_curve_nurbs */
+extern Material defmaterial; /* material.c */
+
static void boundbox_displist(Object *ob);
void free_disp_elem(DispList *dl)
@@ -284,513 +283,6 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i
return 1;
}
-/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */
-
-/* create default shade input... save cpu cycles with ugly global */
-/* XXXX bad code warning: local ShadeInput initialize... */
-static ShadeInput shi;
-static void init_fastshade_shadeinput(Render *re)
-{
- memset(&shi, 0, sizeof(ShadeInput));
- shi.lay= RE_GetScene(re)->lay;
- shi.view[2]= -1.0f;
- shi.passflag= SCE_PASS_COMBINED;
- shi.combinedflag= -1;
-}
-
-static Render *fastshade_get_render(Scene *UNUSED(scene))
-{
- // XXX 2.5: this crashes combined with previewrender
- // due to global R so disabled for now
-#if 0
- /* XXX ugly global still, but we can't do preview while rendering */
- if(G.rendering==0) {
-
- Render *re= RE_GetRender("_Shade View_");
- if(re==NULL) {
- re= RE_NewRender("_Shade View_");
-
- RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */
- }
- return re;
- }
-#endif
-
- return NULL;
-}
-
-/* called on file reading */
-void fastshade_free_render(void)
-{
- Render *re= RE_GetRender("_Shade View_");
-
- if(re) {
- RE_Database_Free(re);
- RE_FreeRender(re);
- }
-}
-
-static int fastshade_customdata_layer_num(int n, int active)
-{
- /* make the active layer the first */
- if (n == active) return 0;
- else if (n < active) return n+1;
- else return n;
-}
-
-static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma)
-{
- CustomDataLayer *layer;
- MTFace *mtface;
- int index, n, needuv= ma->texco & TEXCO_UV;
- char *vertcol;
-
- shi.totuv= 0;
- shi.totcol= 0;
-
- for(index=0; index<fdata->totlayer; index++) {
- layer= &fdata->layers[index];
-
- if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) {
- n= fastshade_customdata_layer_num(shi.totuv, layer->active_rnd);
- mtface= &((MTFace*)layer->data)[a];
-
- shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f;
- shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f;
- shi.uv[shi.totuv].uv[2]= 1.0f;
-
- shi.uv[shi.totuv].name= layer->name;
- shi.totuv++;
- }
- else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) {
- n= fastshade_customdata_layer_num(shi.totcol, layer->active_rnd);
- vertcol= (char*)&((MCol*)layer->data)[a*4 + j];
-
- shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f;
- shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f;
- shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f;
-
- shi.col[shi.totcol].name= layer->name;
- shi.totcol++;
- }
- }
-
- if(needuv && shi.totuv == 0)
- VECCOPY(shi.uv[0].uv, shi.lo);
-
- if(shi.totcol)
- VECCOPY(shi.vcol, shi.col[0].col);
-}
-
-static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2)
-{
- ShadeResult shr;
- int a;
-
- VECCOPY(shi.co, co);
- shi.vn[0]= -nor[0];
- shi.vn[1]= -nor[1];
- shi.vn[2]= -nor[2];
- VECCOPY(shi.vno, shi.vn);
- VECCOPY(shi.facenor, shi.vn);
-
- if(ma->texco) {
- VECCOPY(shi.lo, orco);
-
- if(ma->texco & TEXCO_GLOB) {
- VECCOPY(shi.gl, shi.lo);
- }
- if(ma->texco & TEXCO_WINDOW) {
- VECCOPY(shi.winco, shi.lo);
- }
- if(ma->texco & TEXCO_STICKY) {
- VECCOPY(shi.sticky, shi.lo);
- }
- if(ma->texco & TEXCO_OBJECT) {
- VECCOPY(shi.co, shi.lo);
- }
- if(ma->texco & TEXCO_NORM) {
- VECCOPY(shi.orn, shi.vn);
- }
- if(ma->texco & TEXCO_REFL) {
- float inp= 2.0f * (shi.vn[2]);
- shi.ref[0]= (inp*shi.vn[0]);
- shi.ref[1]= (inp*shi.vn[1]);
- shi.ref[2]= (-1.0f + inp*shi.vn[2]);
- }
- }
-
- shi.mat= ma; /* set each time... node shaders change it */
- RE_shade_external(NULL, &shi, &shr);
-
- a= 256.0f*(shr.combined[0]);
- col1[0]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[1]);
- col1[1]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[2]);
- col1[2]= CLAMPIS(a, 0, 255);
-
- if(col2) {
- shi.vn[0]= -shi.vn[0];
- shi.vn[1]= -shi.vn[1];
- shi.vn[2]= -shi.vn[2];
-
- shi.mat= ma; /* set each time... node shaders change it */
- RE_shade_external(NULL, &shi, &shr);
-
- a= 256.0f*(shr.combined[0]);
- col2[0]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[1]);
- col2[1]= CLAMPIS(a, 0, 255);
- a= 256.0f*(shr.combined[2]);
- col2[2]= CLAMPIS(a, 0, 255);
- }
-}
-
-static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3])
-{
- float tmat[4][4];
- float amb[3]= {0.0f, 0.0f, 0.0f};
- int a;
-
- /* initialize globals in render */
- RE_shade_external(re, NULL, NULL);
-
- /* initialize global here */
- init_fastshade_shadeinput(re);
-
- RE_DataBase_GetView(re, tmat);
- mul_m4_m4m4(mat, ob->obmat, tmat);
-
- invert_m4_m4(tmat, mat);
- copy_m3_m4(imat, tmat);
- if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0);
-
- if (need_orco_r) *need_orco_r= 0;
- for(a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a+1);
- if(ma) {
- init_render_material(ma, 0, amb);
-
- if(ma->texco & TEXCO_ORCO) {
- if (need_orco_r) *need_orco_r= 1;
- }
- }
- }
-}
-
-static void end_fastshade_for_ob(Object *ob)
-{
- int a;
-
- for(a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a+1);
- if(ma)
- end_render_material(ma);
- }
-}
-
-
-static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r)
-{
- Mesh *me= ob->data;
- DerivedMesh *dm;
- MVert *mvert;
- MFace *mface;
- unsigned int *col1, *col2;
- float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3];
- int a, i, need_orco, totface, totvert;
- CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL
- | CD_MASK_MTFACE | CD_MASK_NORMAL;
-
-
- init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
-
- if(need_orco)
- dataMask |= CD_MASK_ORCO;
-
- if (onlyForMesh)
- dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask);
- else
- dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask);
-
- mvert = dm->getVertArray(dm);
- mface = dm->getFaceArray(dm);
- nors = dm->getFaceDataArray(dm, CD_NORMAL);
- totvert = dm->getNumVerts(dm);
- totface = dm->getNumFaces(dm);
- orco= dm->getVertDataArray(dm, CD_ORCO);
-
- if (onlyForMesh) {
- col1 = *col1_r;
- col2 = NULL;
- } else {
- *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1");
-
- if (col2_r && (me->flag & ME_TWOSIDED))
- col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2");
- else
- col2 = NULL;
-
- if (col2_r) *col2_r = col2;
- }
-
- /* vertexnormals */
- vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp");
- for (a=0; a<totvert; a++) {
- MVert *mv = &mvert[a];
- float *vn= &vnors[a*3];
- float xn= mv->no[0];
- float yn= mv->no[1];
- float zn= mv->no[2];
-
- /* transpose ! */
- vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
- vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
- vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
- normalize_v3(vn);
- }
-
- for (i=0; i<totface; i++) {
- extern Material defmaterial; /* material.c */
- MFace *mf= &mface[i];
- Material *ma= give_current_material(ob, mf->mat_nr+1);
- int j, vidx[4], nverts= mf->v4?4:3;
- unsigned char *col1base= (unsigned char*) &col1[i*4];
- unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
- float nor[3], n1[3];
-
- if(ma==NULL) ma= &defmaterial;
-
- vidx[0]= mf->v1;
- vidx[1]= mf->v2;
- vidx[2]= mf->v3;
- vidx[3]= mf->v4;
-
- if (nors) {
- VECCOPY(nor, &nors[i*3]);
- } else {
- if (mf->v4)
- normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co);
- else
- normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co);
- }
-
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- normalize_v3(n1);
-
- for (j=0; j<nverts; j++) {
- MVert *mv= &mvert[vidx[j]];
- char *col1= (char*)&col1base[j*4];
- char *col2= (char*)(col2base?&col2base[j*4]:NULL);
- float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
-
- mul_v3_m4v3(vec, mat, mv->co);
-
- mul_v3_v3fl(vec, vn, 0.001f);
-
- fastshade_customdata(&dm->faceData, i, j, ma);
- fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2);
- }
- }
- MEM_freeN(vnors);
-
- dm->release(dm);
-
- end_fastshade_for_ob(ob);
-}
-
-void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me)
-{
- Render *re= fastshade_get_render(scene);
- int a;
- char *cp;
- unsigned int *mcol= (unsigned int*)me->mcol;
-
- if(re) {
- mesh_create_shadedColors(re, ob, 1, &mcol, NULL);
- me->mcol= (MCol*)mcol;
-
- /* swap bytes */
- for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) {
- SWAP(char, cp[0], cp[3]);
- SWAP(char, cp[1], cp[2]);
- }
- }
-}
-
-/* has base pointer, to check for layer */
-/* called from drawobject.c */
-void shadeDispList(Scene *scene, Base *base)
-{
- Object *ob= base->object;
- DispList *dl, *dlob;
- Material *ma = NULL;
- Render *re;
- float imat[3][3], mat[4][4], vec[3];
- float *fp, *nor, n1[3];
- unsigned int *col1;
- int a, need_orco;
-
- re= fastshade_get_render(scene);
- if(re==NULL)
- return;
-
- dl = find_displist(&ob->disp, DL_VERTCOL);
- if (dl) {
- BLI_remlink(&ob->disp, dl);
- free_disp_elem(dl);
- }
-
- if(ob->type==OB_MESH) {
- dl= MEM_callocN(sizeof(DispList), "displistshade");
- dl->type= DL_VERTCOL;
-
- mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2);
-
- /* add dl to ob->disp after mesh_create_shadedColors, because it
- might indirectly free ob->disp */
- BLI_addtail(&ob->disp, dl);
- }
- else {
-
- init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
-
- if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-
- /* now we need the normals */
- dl= ob->disp.first;
-
- while(dl) {
- extern Material defmaterial; /* material.c */
-
- dlob= MEM_callocN(sizeof(DispList), "displistshade");
- BLI_addtail(&ob->disp, dlob);
- dlob->type= DL_VERTCOL;
- dlob->parts= dl->parts;
- dlob->nr= dl->nr;
-
- if(dl->type==DL_INDEX3) {
- col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
- }
- else {
- col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1");
- }
-
-
- ma= give_current_material(ob, dl->col+1);
- if(ma==NULL) ma= &defmaterial;
-
- if(dl->type==DL_INDEX3) {
- if(dl->nors) {
- /* there's just one normal */
- n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2];
- n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2];
- n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2];
- normalize_v3(n1);
-
- fp= dl->verts;
-
- a= dl->nr;
- while(a--) {
- mul_v3_m4v3(vec, mat, fp);
-
- fastshade(vec, n1, fp, ma, (char *)col1, NULL);
-
- fp+= 3; col1++;
- }
- }
- }
- else if(dl->type==DL_SURF) {
- if(dl->nors) {
- a= dl->nr*dl->parts;
- fp= dl->verts;
- nor= dl->nors;
-
- while(a--) {
- mul_v3_m4v3(vec, mat, fp);
-
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- normalize_v3(n1);
-
- fastshade(vec, n1, fp, ma, (char *)col1, NULL);
-
- fp+= 3; nor+= 3; col1++;
- }
- }
- }
- dl= dl->next;
- }
- }
- else if(ob->type==OB_MBALL) {
- /* there are normals already */
- dl= ob->disp.first;
-
- while(dl) {
-
- if(dl->type==DL_INDEX4) {
- if(dl->nors) {
- extern Material defmaterial; /* material.c */
-
- if(dl->col1) MEM_freeN(dl->col1);
- col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
-
- ma= give_current_material(ob, dl->col+1);
- if(ma==NULL) ma= &defmaterial;
-
- fp= dl->verts;
- nor= dl->nors;
-
- a= dl->nr;
- while(a--) {
- mul_v3_m4v3(vec, mat, fp);
-
- /* transpose ! */
- n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2];
- n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2];
- n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
- normalize_v3(n1);
-
- fastshade(vec, n1, fp, ma, (char *)col1, NULL);
-
- fp+= 3; col1++; nor+= 3;
- }
- }
- }
- dl= dl->next;
- }
- }
-
- end_fastshade_for_ob(ob);
- }
-}
-
-/* frees render and shade part of displists */
-/* note: dont do a shade again, until a redraw happens */
-void reshadeall_displist(Scene *scene)
-{
- Base *base;
- Object *ob;
-
- fastshade_free_render();
-
- for(base= scene->base.first; base; base= base->next) {
- ob= base->object;
-
- if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL))
- freedisplist(&ob->disp);
-
- if(base->lay & scene->lay) {
- /* Metaballs have standard displist at the Object */
- if(ob->type==OB_MBALL) shadeDispList(scene, base);
- }
- }
-}
-
/* ****************** make displists ********************* */
static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender)
@@ -984,16 +476,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
dl= dl->next;
}
- if(totvert && BLI_edgefill(0)) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
-
- /* count faces */
- tot= 0;
- efa= fillfacebase.first;
- while(efa) {
- tot++;
- efa= efa->next;
- }
-
+ if(totvert && (tot= BLI_edgefill(0))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) {
if(tot) {
dlnew= MEM_callocN(sizeof(DispList), "filldisplist");
dlnew->type= DL_INDEX3;
@@ -1973,8 +1456,9 @@ static void boundbox_displist(Object *ob)
}
if(!doit) {
- min[0] = min[1] = min[2] = -1.0f;
- max[0] = max[1] = max[2] = 1.0f;
+ /* there's no geometry in displist, use zero-sized boundbox */
+ zero_v3(min);
+ zero_v3(max);
}
}
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index ee46bef6038..4b95c44f55f 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -241,6 +241,16 @@ static void precalculate_effector(EffectorCache *eff)
}
else if(eff->psys)
psys_update_particle_tree(eff->psys, eff->scene->r.cfra);
+
+ /* Store object velocity */
+ if(eff->ob) {
+ float old_vel[3];
+
+ where_is_object_time(eff->scene, eff->ob, cfra - 1.0f);
+ copy_v3_v3(old_vel, eff->ob->obmat[3]);
+ where_is_object_time(eff->scene, eff->ob, cfra);
+ sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
+ }
}
static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
{
@@ -680,10 +690,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
Object *ob = eff->ob;
Object obcopy = *ob;
- /* XXX this is not thread-safe, but used from multiple threads by
- particle system */
- where_is_object_time(eff->scene, ob, cfra);
-
/* use z-axis as normal*/
normalize_v3_v3(efd->nor, ob->obmat[2]);
@@ -702,13 +708,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
VECCOPY(efd->loc, ob->obmat[3]);
}
- if(real_velocity) {
- VECCOPY(efd->vel, ob->obmat[3]);
-
- where_is_object_time(eff->scene, ob, cfra - 1.0f);
-
- sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]);
- }
+ if(real_velocity)
+ copy_v3_v3(efd->vel, eff->velocity);
*eff->ob = obcopy;
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index b1272ee2d53..d6a9d950015 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -2039,7 +2039,7 @@ float evaluate_fcurve (FCurve *fcu, float evaltime)
* here so that the curve can be sampled correctly
*/
if (fcu->flag & FCURVE_INT_VALUES)
- cvalue= (float)((int)cvalue);
+ cvalue= floorf(cvalue + 0.5f);
/* return evaluated value */
return cvalue;
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 09c189a8847..9effd25c142 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -125,25 +125,33 @@ struct PreviewImage* BKE_previewimg_create(void)
prv_img = MEM_callocN(sizeof(PreviewImage), "img_prv");
- for (i=0; i<PREVIEW_MIPMAPS; ++i) {
+ for (i=0; i<NUM_ICON_SIZES; ++i) {
prv_img->changed[i] = 1;
prv_img->changed_timestamp[i] = 0;
}
return prv_img;
}
-void BKE_previewimg_free(PreviewImage **prv)
+void BKE_previewimg_freefunc(void *link)
{
- if(prv && (*prv)) {
+ PreviewImage *prv = (PreviewImage *)link;
+ if (prv) {
int i;
-
- for (i=0; i<PREVIEW_MIPMAPS;++i) {
- if ((*prv)->rect[i]) {
- MEM_freeN((*prv)->rect[i]);
- (*prv)->rect[i] = NULL;
+
+ for (i=0; i<NUM_ICON_SIZES;++i) {
+ if (prv->rect[i]) {
+ MEM_freeN(prv->rect[i]);
+ prv->rect[i] = NULL;
}
}
- MEM_freeN((*prv));
+ MEM_freeN(prv);
+ }
+}
+
+void BKE_previewimg_free(PreviewImage **prv)
+{
+ if(prv && (*prv)) {
+ BKE_previewimg_freefunc(*prv);
*prv = NULL;
}
}
@@ -155,7 +163,7 @@ struct PreviewImage* BKE_previewimg_copy(PreviewImage *prv)
if (prv) {
prv_img = MEM_dupallocN(prv);
- for (i=0; i < PREVIEW_MIPMAPS; ++i) {
+ for (i=0; i < NUM_ICON_SIZES; ++i) {
if (prv->rect[i]) {
prv_img->rect[i] = MEM_dupallocN(prv->rect[i]);
} else {
@@ -237,7 +245,7 @@ void BKE_icon_changed(int id)
/* all previews changed */
if (prv) {
int i;
- for (i=0; i<PREVIEW_MIPMAPS; ++i) {
+ for (i=0; i<NUM_ICON_SIZES; ++i) {
prv->changed[i] = 1;
prv->changed_timestamp[i]++;
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 22d19c5484f..ab67d7e3f25 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -381,9 +381,7 @@ Image *BKE_add_image_file(const char *name)
ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE);
BLI_strncpy(ima->name, name, sizeof(ima->name));
- /* do a wild guess! */
- if(BLI_testextensie(name, ".avi") || BLI_testextensie(name, ".mov")
- || BLI_testextensie(name, ".mpg") || BLI_testextensie(name, ".mp4"))
+ if(BLI_testextensie_array(name, imb_ext_movie))
ima->source= IMA_SRC_MOVIE;
return ima;
@@ -434,6 +432,7 @@ Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *n
ima->gen_x= width;
ima->gen_y= height;
ima->gen_type= uvtestgrid;
+ ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
ibuf= add_ibuf_size(width, height, name, depth, floatbuf, uvtestgrid, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
@@ -1031,7 +1030,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec
BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
pad= BLF_width_max(mono);
- /* use 'h_fixed' rather then 'h', aligns better */
+ /* use 'h_fixed' rather than 'h', aligns better */
h_fixed= BLF_height_max(mono);
y_ofs = -BLF_descender(mono);
@@ -2174,7 +2173,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r)
/* UV testgrid or black or solid etc */
if(ima->gen_x==0) ima->gen_x= 1024;
if(ima->gen_y==0) ima->gen_y= 1024;
- ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, 0, ima->gen_type, color);
+ ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color);
image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0);
ima->ok= IMA_OK_LOADED;
}
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 4b532362cd8..8b0cfb1d156 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -63,6 +63,7 @@
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_object.h"
+#include "BKE_deform.h"
#include "RNA_access.h"
@@ -1005,7 +1006,7 @@ static float *get_weights_array(Object *ob, char *vgroup)
MDeformVert *dvert= NULL;
EditMesh *em= NULL;
EditVert *eve;
- int totvert= 0, index= 0;
+ int totvert= 0, defgrp_index= 0;
/* no vgroup string set? */
if(vgroup[0]==0) return NULL;
@@ -1028,10 +1029,10 @@ static float *get_weights_array(Object *ob, char *vgroup)
if(dvert==NULL) return NULL;
/* find the group (weak loop-in-loop) */
- index= defgroup_name_index(ob, vgroup);
- if(index >= 0) {
+ defgrp_index= defgroup_name_index(ob, vgroup);
+ if(defgrp_index >= 0) {
float *weights;
- int i, j;
+ int i;
weights= MEM_callocN(totvert*sizeof(float), "weights");
@@ -1040,23 +1041,13 @@ static float *get_weights_array(Object *ob, char *vgroup)
dvert= CustomData_em_get(&em->vdata, eve->data, CD_MDEFORMVERT);
if(dvert) {
- for(j=0; j<dvert->totweight; j++) {
- if(dvert->dw[j].def_nr == index) {
- weights[i]= dvert->dw[j].weight;
- break;
- }
- }
+ weights[i]= defvert_find_weight(dvert, defgrp_index);
}
}
}
else {
for(i=0; i < totvert; i++, dvert++) {
- for(j=0; j<dvert->totweight; j++) {
- if(dvert->dw[j].def_nr == index) {
- weights[i]= dvert->dw[j].weight;
- break;
- }
- }
+ weights[i]= defvert_find_weight(dvert, defgrp_index);
}
}
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index f0ac7040deb..094214858f9 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -607,7 +607,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
if(cd->no_rot_axis) { /* set by caller */
- /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then
+ /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than
* changing the axis before calculating the tilt but serves much the same purpose */
float dir_flat[3]={0,0,0}, q[4];
copy_v3_v3(dir_flat, dir);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index fd58dc2dfc0..3f01c55e935 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -258,9 +258,8 @@ Material *localize_material(Material *ma)
man->preview = NULL;
- if(ma->nodetree) {
+ if(ma->nodetree)
man->nodetree= ntreeLocalize(ma->nodetree);
- }
man->gpumaterial.first= man->gpumaterial.last= NULL;
@@ -551,7 +550,7 @@ Material *material_pop_id(ID *id, int index)
Material **mat;
if(index + 1 != (*totcol))
- memmove((*matar), (*matar) + 1, (*totcol) - (index + 1));
+ memmove((*matar)+index, (*matar)+(index+1), sizeof(void *) * ((*totcol) - (index + 1)));
(*totcol)--;
@@ -868,6 +867,10 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
if(ma->strand_surfnor > 0.0f)
ma->mode_l |= MA_STR_SURFDIFF;
+
+ /* parses the geom+tex nodes */
+ if(ma->nodetree && ma->use_nodes)
+ ntreeShaderGetTexcoMode(ma->nodetree, r_mode, &ma->texco, &ma->mode_l);
}
static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode, float *amb)
@@ -888,8 +891,6 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode
init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb);
}
}
- /* parses the geom+tex nodes */
- ntreeShaderGetTexcoMode(ntree, r_mode, &basemat->texco, &basemat->mode_l);
}
void init_render_material(Material *mat, int r_mode, float *amb)
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 5706a3997e6..88a670ecb22 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -465,18 +465,19 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv
return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0, 0);
}
-static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, int lvl, int simple, int optimal)
+static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv)
{
SubsurfModifierData smd= {{NULL}};
smd.levels = smd.renderLevels = lvl;
- smd.flags |= eSubsurfModifierFlag_SubsurfUv;
+ if(!plain_uv)
+ smd.flags |= eSubsurfModifierFlag_SubsurfUv;
if(simple)
smd.subdivType = ME_SIMPLE_SUBSURF;
if(optimal)
smd.flags |= eSubsurfModifierFlag_ControlEdges;
- return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0);
+ return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
}
@@ -591,7 +592,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
/* subdivide the mesh to highest level without displacements */
cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0);
+ origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
cddm->release(cddm);
/* calc disps */
@@ -626,7 +627,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl
/* create subsurf DM from original mesh at high level */
cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0);
+ highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
/* create multires DM from original mesh at low level */
lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple);
@@ -830,7 +831,7 @@ static void multiresModifier_update(DerivedMesh *dm)
else cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0);
+ highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
/* create multires DM from original mesh and displacements */
lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple);
@@ -884,7 +885,7 @@ static void multiresModifier_update(DerivedMesh *dm)
else cddm = CDDM_from_mesh(me, NULL);
DM_set_only_copy(cddm, CD_MASK_BAREMESH);
- subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0);
+ subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
cddm->release(cddm);
multiresModifier_disp_run(dm, me, 1, 0, subdm->getGridData(subdm), mmd->totlvl);
@@ -927,7 +928,8 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca
return dm;
result = subsurf_dm_create_local(ob, dm, lvl,
- mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges);
+ mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges,
+ mmd->flags & eMultiresModifierFlag_PlainUv);
if(!local_mmd) {
ccgdm = (CCGDerivedMesh*)result;
@@ -1020,7 +1022,7 @@ static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, in
static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
{
- int newlvl = log(sqrt(mdisp->totdisp)-1)/log(2);
+ int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2;
int oldlvl = newlvl+1;
int oldside = multires_side_tot[oldlvl];
int newside = multires_side_tot[newlvl];
@@ -1633,7 +1635,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
MEM_freeN(vertCos);
/* scaled ccgDM for tangent space of object with applied scale */
- dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0);
+ dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv);
cddm->release(cddm);
/*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/
@@ -1756,7 +1758,7 @@ void multires_topology_changed(Scene *scene, Object *ob)
int nvert= me->mface[i].v4 ? 4 : 3;
/* allocate memory for mdisp, the whole disp layer would be erased otherwise */
- if(!mdisp->totdisp) {
+ if(!mdisp->totdisp || !mdisp->disps) {
if(grid) {
mdisp->totdisp= nvert*grid;
mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology");
@@ -1997,6 +1999,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;
@@ -2022,6 +2025,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};
@@ -2148,7 +2206,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..13469e0b58b 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -32,8 +32,10 @@
*/
-#ifdef WITH_PYTHON
-#include <Python.h>
+#if 0 /* pynodes commented for now */
+# ifdef WITH_PYTHON
+# include <Python.h>
+# endif
#endif
#include "MEM_guardedalloc.h"
@@ -350,7 +352,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 +2074,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 +2202,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 +2228,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;
@@ -2415,6 +2418,11 @@ void ntreeBeginExecTree(bNodeTree *ntree)
if(ntree->type==NTREE_COMPOSIT)
composit_begin_exec(ntree, ntree->stack);
+
+ /* ensures only a single output node is enabled, texnode allows multiple though */
+ if(ntree->type!=NTREE_TEXTURE)
+ ntreeSetOutput(ntree);
+
}
ntree->init |= NTREE_EXEC_INIT;
@@ -2762,9 +2770,6 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
/* fixed seed, for example noise texture */
BLI_srandom(rd->cfra);
- /* ensures only a single output node is enabled */
- ntreeSetOutput(ntree);
-
/* sets need_exec tags in nodes */
curnode = totnode= setExecutableNodes(ntree, &thdata);
@@ -3153,6 +3158,8 @@ static void force_hidden_passes(bNode *node, int passflag)
if(!(passflag & SCE_PASS_INDIRECT)) sock->flag |= SOCK_UNAVAIL;
sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXOB);
if(!(passflag & SCE_PASS_INDEXOB)) sock->flag |= SOCK_UNAVAIL;
+ sock= BLI_findlink(&node->outputs, RRES_OUT_INDEXMA);
+ if(!(passflag & SCE_PASS_INDEXMA)) sock->flag |= SOCK_UNAVAIL;
sock= BLI_findlink(&node->outputs, RRES_OUT_MIST);
if(!(passflag & SCE_PASS_MIST)) sock->flag |= SOCK_UNAVAIL;
sock= BLI_findlink(&node->outputs, RRES_OUT_EMIT);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 79a4e6443d2..48c1c2b9b6e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -869,11 +869,32 @@ Lamp *copy_lamp(Lamp *la)
lan->curfalloff = curvemapping_copy(la->curfalloff);
-#if 0 // XXX old animation system
- id_us_plus((ID *)lan->ipo);
-#endif // XXX old animation system
+ if(la->preview)
+ lan->preview = BKE_previewimg_copy(la->preview);
+
+ return lan;
+}
+
+Lamp *localize_lamp(Lamp *la)
+{
+ Lamp *lan;
+ int a;
+
+ lan= copy_libblock(la);
+ BLI_remlink(&G.main->lamp, lan);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(lan->mtex[a]) {
+ lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
+ memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
+ /* free lamp decrements */
+ id_us_plus((ID *)lan->mtex[a]->tex);
+ }
+ }
+
+ lan->curfalloff = curvemapping_copy(la->curfalloff);
- if (la->preview) lan->preview = BKE_previewimg_copy(la->preview);
+ lan->preview= NULL;
return lan;
}
@@ -1630,12 +1651,6 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
/* there is also a timing calculation in drawobject() */
-static int no_speed_curve= 0;
-
-void disable_speed_curve(int val)
-{
- no_speed_curve= val;
-}
// XXX THIS CRUFT NEEDS SERIOUS RECODING ASAP!
/* ob can be NULL */
@@ -1673,21 +1688,20 @@ void object_rot_to_mat3(Object *ob, float mat[][3])
{
float rmat[3][3], dmat[3][3];
- /* initialise the delta-rotation matrix, which will get (pre)multiplied
+ /* 'dmat' is the delta-rotation matrix, which will get (pre)multiplied
* with the rotation matrix to yield the appropriate rotation
*/
- unit_m3(dmat);
-
+
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
if (ob->rotmode > 0) {
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
- eulO_to_mat3( rmat,ob->rot, ob->rotmode);
- eulO_to_mat3( dmat,ob->drot, ob->rotmode);
+ eulO_to_mat3(rmat, ob->rot, ob->rotmode);
+ eulO_to_mat3(dmat, ob->drot, ob->rotmode);
}
else if (ob->rotmode == ROT_MODE_AXISANGLE) {
/* axis-angle - not really that great for 3D-changing orientations */
- axis_angle_to_mat3( rmat,ob->rotAxis, ob->rotAngle);
- axis_angle_to_mat3( dmat,ob->drotAxis, ob->drotAngle);
+ axis_angle_to_mat3(rmat, ob->rotAxis, ob->rotAngle);
+ axis_angle_to_mat3(dmat, ob->drotAxis, ob->drotAngle);
}
else {
/* quats are normalised before use to eliminate scaling issues */
@@ -1722,9 +1736,22 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat)
ob->rotAngle -= ob->drotAngle;
break;
default: /* euler */
- if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, mat);
- else mat3_to_eulO(ob->rot, ob->rotmode, mat);
- sub_v3_v3(ob->rot, ob->drot);
+ {
+ float quat[4];
+ float dquat[4];
+ float tmat[3][3];
+
+ /* without drot we could apply 'mat' directly */
+ mat3_to_quat(quat, mat);
+ eulO_to_quat(dquat, ob->drot, ob->rotmode);
+ invert_qt(dquat);
+ mul_qt_qtqt(quat, dquat, quat);
+ quat_to_mat3(tmat, quat);
+ /* end drot correction */
+
+ if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat);
+ else mat3_to_eulO(ob->rot, ob->rotmode, tmat);
+ }
}
}
@@ -1740,7 +1767,7 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const
mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */
object_apply_mat4(ob, rmat, use_compat, FALSE);
- /* same as below, use rmat rather then mat */
+ /* same as below, use rmat rather than mat */
mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat);
object_mat3_to_rot(ob, rot, use_compat);
}
@@ -1916,9 +1943,10 @@ static void give_parvert(Object *par, int nr, float *vec)
if(dm) {
MVert *mvert= dm->getVertArray(dm);
int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX);
- int i, count = 0, vindex, numVerts = dm->getNumVerts(dm);
+ int i, vindex, numVerts = dm->getNumVerts(dm);
/* get the average of all verts with (original index == nr) */
+ count= 0;
for(i = 0; i < numVerts; i++) {
vindex= (index)? index[i]: i;
@@ -2362,24 +2390,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:
@@ -2391,25 +2437,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]);
@@ -2419,7 +2467,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;
}
}
@@ -2597,11 +2644,12 @@ void object_handle_update(Scene *scene, Object *ob)
#else /* ensure CD_MASK_BAREMESH for now */
EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL;
+ unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH;
if(em) {
- makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */
BKE_mesh_end_editmesh(ob->data, em);
} else
- makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH);
+ makeDerivedMesh(scene, ob, NULL, data_mask);
#endif
}
@@ -3012,9 +3060,14 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int
if(newkey || from_mix==FALSE) {
kb= add_keyblock(key, name);
-
- /* create from lattice */
- latt_to_key(lt, kb);
+ if (!newkey) {
+ KeyBlock *basekb= (KeyBlock *)key->block.first;
+ kb->data= MEM_dupallocN(basekb->data);
+ kb->totelem= basekb->totelem;
+ }
+ else {
+ latt_to_key(lt, kb);
+ }
}
else {
/* copy from current values */
@@ -3050,7 +3103,10 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int
KeyBlock *basekb= (KeyBlock *)key->block.first;
kb->data= MEM_dupallocN(basekb->data);
kb->totelem= basekb->totelem;
- } else curve_to_key(cu, kb, lb);
+ }
+ else {
+ curve_to_key(cu, kb, lb);
+ }
}
else {
/* copy from current values */
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 5be492d1108..d00eb6192da 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -85,8 +85,11 @@ Brush *paint_brush(Paint *p)
void paint_brush_set(Paint *p, Brush *br)
{
- if(p)
+ if(p) {
+ id_us_min((ID *)p->brush);
+ id_us_plus((ID *)br);
p->brush= br;
+ }
}
int paint_facesel_test(Object *ob)
@@ -110,12 +113,17 @@ void paint_init(Paint *p, const char col[3])
p->flags |= PAINT_SHOW_BRUSH;
}
-void free_paint(Paint *UNUSED(paint))
+void free_paint(Paint *paint)
{
- /* nothing */
+ id_us_min((ID *)paint->brush);
}
+/* called when copying scene settings, so even if 'src' and 'tar' are the same
+ * still do a id_us_plus(), rather then if we were copying betweem 2 existing
+ * scenes where a matching value should decrease the existing user count as
+ * with paint_brush_set() */
void copy_paint(Paint *src, Paint *tar)
{
tar->brush= src->brush;
+ id_us_plus((ID *)tar->brush);
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 5ec4c36177f..5995b895061 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2889,8 +2889,6 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
if(psys_in_edit_mode(sim->scene, psys))
if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0)
return;
-
- BLI_srandom(psys->seed);
keyed = psys->flag & PSYS_KEYED;
baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR;
@@ -3057,7 +3055,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
ParticleKey result;
float birthtime = 0.0f, dietime = 0.0f;
- float t, time = 0.0f, keytime = 0.0f, frs_sec;
+ float t, time = 0.0f, keytime = 0.0f /*, frs_sec */;
float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f};
int k, i;
int steps = (int)pow(2.0, (double)pset->draw_step);
@@ -3078,7 +3076,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
recalc_set = 1;
}
- frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f;
+ /* frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; */ /* UNUSED */
if(pset->brushtype == PE_BRUSH_WEIGHT) {
;/* use weight painting colors now... */
@@ -3534,6 +3532,8 @@ static void default_particle_settings(ParticleSettings *part)
part->path_start = 0.0f;
part->path_end = 1.0f;
+ part->bb_size[0] = part->bb_size[1] = 1.0f;
+
part->keyed_loops = 1;
part->color_vec_max = 1.f;
@@ -4018,7 +4018,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);
@@ -4368,58 +4372,45 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
Object *ob = sim->ob;
ParticleSystem *psys = sim->psys;
ParticleSystemModifierData *psmd = sim->psmd;
- float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4];
- float xvec[3] = {-1.0, 0.0, 0.0}, q[4], nmat[3][3];
+ float loc[3], nor[3], vec[3], side[3], len;
+ float xvec[3] = {-1.0, 0.0, 0.0}, nmat[3][3];
sub_v3_v3v3(vec, (cache+cache->steps)->co, cache->co);
len= normalize_v3(vec);
- if(psys->part->rotmode) {
- if(pa == NULL)
- pa= psys->particles+cpa->pa[0];
-
- vec_to_quat( q,xvec, ob->trackflag, ob->upflag);
- quat_to_mat4( obrotmat,q);
- obrotmat[3][3]= 1.0f;
+ if(pa == NULL && psys->part->childflat != PART_CHILD_FACES)
+ pa = psys->particles + cpa->pa[0];
- quat_to_mat4( qmat,pa->state.rot);
- mul_m4_m4m4(mat, obrotmat, qmat);
- }
- else {
- if(pa == NULL && psys->part->childflat != PART_CHILD_FACES)
- pa = psys->particles + cpa->pa[0];
-
- if(pa)
- psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
- else
- psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0);
+ if(pa)
+ psys_particle_on_emitter(psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc,nor,0,0,0,0);
+ else
+ psys_particle_on_emitter(psmd,PART_FROM_FACE,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,loc,nor,0,0,0,0);
- copy_m3_m4(nmat, ob->imat);
- transpose_m3(nmat);
- mul_m3_v3(nmat, nor);
-
- /* make sure that we get a proper side vector */
- if(fabs(dot_v3v3(nor,vec))>0.999999) {
- if(fabs(dot_v3v3(nor,xvec))>0.999999) {
- nor[0] = 0.0f;
- nor[1] = 1.0f;
- nor[2] = 0.0f;
- }
- else {
- nor[0] = 1.0f;
- nor[1] = 0.0f;
- nor[2] = 0.0f;
- }
- }
- cross_v3_v3v3(side, nor, vec);
- normalize_v3(side);
- cross_v3_v3v3(nor, vec, side);
+ copy_m3_m4(nmat, ob->imat);
+ transpose_m3(nmat);
+ mul_m3_v3(nmat, nor);
- unit_m4(mat);
- VECCOPY(mat[0], vec);
- VECCOPY(mat[1], side);
- VECCOPY(mat[2], nor);
+ /* make sure that we get a proper side vector */
+ if(fabs(dot_v3v3(nor,vec))>0.999999) {
+ if(fabs(dot_v3v3(nor,xvec))>0.999999) {
+ nor[0] = 0.0f;
+ nor[1] = 1.0f;
+ nor[2] = 0.0f;
+ }
+ else {
+ nor[0] = 1.0f;
+ nor[1] = 0.0f;
+ nor[2] = 0.0f;
+ }
}
+ cross_v3_v3v3(side, nor, vec);
+ normalize_v3(side);
+ cross_v3_v3v3(nor, vec, side);
+
+ unit_m4(mat);
+ VECCOPY(mat[0], vec);
+ VECCOPY(mat[1], side);
+ VECCOPY(mat[2], nor);
*scale= len;
}
@@ -4501,8 +4492,8 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3]
mul_v3_fl(tvec, -sin(bb->tilt * (float)M_PI));
VECADD(yvec, yvec, tvec);
- mul_v3_fl(xvec, bb->size);
- mul_v3_fl(yvec, bb->size);
+ mul_v3_fl(xvec, bb->size[0]);
+ mul_v3_fl(yvec, bb->size[1]);
VECADDFAC(center, bb->vec, xvec, bb->offset[0]);
VECADDFAC(center, center, yvec, bb->offset[1]);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index c2aa297b174..1423f520b95 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -890,7 +890,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
if(ctx->tree){
KDTreeNearest ptn[10];
int w,maxw;//, do_seams;
- float maxd,mind,/*dd,*/totw= 0.0f;
+ float maxd /*, mind,dd */, totw= 0.0f;
int parent[10];
float pweight[10];
@@ -899,7 +899,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch
maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,NULL,ptn);
maxd=ptn[maxw-1].dist;
- mind=ptn[0].dist;
+ /* mind=ptn[0].dist; */ /* UNUSED */
/* the weights here could be done better */
for(w=0; w<maxw; w++){
@@ -1250,7 +1250,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D
double step, pos;
step= (totpart < 2) ? 0.5 : 1.0/(double)totpart;
- pos= 1e-16; /* tiny offset to avoid zero weight face */
+ pos= 1e-6; /* tiny offset to avoid zero weight face */
i= 0;
for(p=0; p<totpart; p++, pos+=step) {
@@ -1562,8 +1562,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
}
}
}
-/* sets particle to the emitter surface with initial velocity & rotation */
-void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
+void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra)
{
Object *ob = sim->ob;
ParticleSystem *psys = sim->psys;
@@ -1575,17 +1574,6 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
float q_phase[4];
int p = pa - psys->particles;
part=psys->part;
-
- /* get precise emitter matrix if particle is born */
- if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
- /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
- while(ob) {
- BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
- ob = ob->parent;
- }
- ob = sim->ob;
- where_is_object_time(sim->scene, ob, pa->time);
- }
/* get birth location from object */
if(part->tanfac != 0.f)
@@ -1594,7 +1582,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
/* get possible textural influence */
- psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra);
+ psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra);
/* particles live in global space so */
/* let's convert: */
@@ -1654,37 +1642,27 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
mat4_to_quat(rot,ob->obmat);
mul_qt_qtqt(r_rot,r_rot,rot);
}
-#if 0
- }
-#endif
if(part->phystype==PART_PHYS_BOIDS && pa->boid) {
- BoidParticle *bpa = pa->boid;
float dvec[3], q[4], mat[3][3];
- copy_v3_v3(pa->state.co,loc);
+ copy_v3_v3(state->co,loc);
/* boids don't get any initial velocity */
- zero_v3(pa->state.vel);
+ zero_v3(state->vel);
/* boids store direction in ave */
if(fabsf(nor[2])==1.0f) {
- sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]);
- normalize_v3(pa->state.ave);
+ sub_v3_v3v3(state->ave, loc, ob->obmat[3]);
+ normalize_v3(state->ave);
}
else {
- VECCOPY(pa->state.ave, nor);
+ VECCOPY(state->ave, nor);
}
- /* and gravity in r_ve */
- bpa->gravity[0] = bpa->gravity[1] = 0.0f;
- bpa->gravity[2] = -1.0f;
- if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
- && sim->scene->physics_settings.gravity[2]!=0.0f)
- bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
/* calculate rotation matrix */
- project_v3_v3v3(dvec, r_vel, pa->state.ave);
- sub_v3_v3v3(mat[0], pa->state.ave, dvec);
+ project_v3_v3v3(dvec, r_vel, state->ave);
+ sub_v3_v3v3(mat[0], state->ave, dvec);
normalize_v3(mat[0]);
negate_v3_v3(mat[2], r_vel);
normalize_v3(mat[2]);
@@ -1692,12 +1670,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* apply rotation */
mat3_to_quat_is_ok( q,mat);
- copy_qt_qt(pa->state.rot, q);
-
- bpa->data.health = part->boids->health;
- bpa->data.mode = eBoidMode_InAir;
- bpa->data.state_id = ((BoidState*)part->boids->states.first)->id;
- bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f;
+ copy_qt_qt(state->rot, q);
}
else {
/* conversion done so now we apply new: */
@@ -1710,7 +1683,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* *emitter velocity */
if(dtime != 0.f && part->obfac != 0.f){
- sub_v3_v3v3(vel, loc, pa->state.co);
+ sub_v3_v3v3(vel, loc, state->co);
mul_v3_fl(vel, part->obfac/dtime);
}
@@ -1747,13 +1720,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
if(part->partfac != 0.f)
madd_v3_v3fl(vel, p_vel, part->partfac);
- mul_v3_v3fl(pa->state.vel, vel, ptex.ivel);
+ mul_v3_v3fl(state->vel, vel, ptex.ivel);
/* -location from emitter */
- copy_v3_v3(pa->state.co,loc);
+ copy_v3_v3(state->co,loc);
/* -rotation */
- unit_qt(pa->state.rot);
+ unit_qt(state->rot);
if(part->rotmode){
/* create vector into which rotation is aligned */
@@ -1793,25 +1766,64 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
/* combine base rotation & phase */
- mul_qt_qtqt(pa->state.rot, rot, q_phase);
+ mul_qt_qtqt(state->rot, rot, q_phase);
}
/* -angular velocity */
- zero_v3(pa->state.ave);
+ zero_v3(state->ave);
if(part->avemode){
switch(part->avemode){
case PART_AVE_SPIN:
- copy_v3_v3(pa->state.ave, vel);
+ copy_v3_v3(state->ave, vel);
break;
case PART_AVE_RAND:
- copy_v3_v3(pa->state.ave, r_ave);
+ copy_v3_v3(state->ave, r_ave);
break;
}
- normalize_v3(pa->state.ave);
- mul_v3_fl(pa->state.ave,part->avefac);
+ normalize_v3(state->ave);
+ mul_v3_fl(state->ave, part->avefac);
+ }
+ }
+}
+/* sets particle to the emitter surface with initial velocity & rotation */
+void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
+{
+ Object *ob = sim->ob;
+ ParticleSystem *psys = sim->psys;
+ ParticleSettings *part;
+ ParticleTexture ptex;
+ int p = pa - psys->particles;
+ part=psys->part;
+
+ /* get precise emitter matrix if particle is born */
+ if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) {
+ /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
+ while(ob) {
+ BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM);
+ ob = ob->parent;
}
+ ob = sim->ob;
+ where_is_object_time(sim->scene, ob, pa->time);
+ }
+
+ psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra);
+
+ if(part->phystype==PART_PHYS_BOIDS && pa->boid) {
+ BoidParticle *bpa = pa->boid;
+
+ /* and gravity in r_ve */
+ bpa->gravity[0] = bpa->gravity[1] = 0.0f;
+ bpa->gravity[2] = -1.0f;
+ if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)
+ && sim->scene->physics_settings.gravity[2]!=0.0f)
+ bpa->gravity[2] = sim->scene->physics_settings.gravity[2];
+
+ bpa->data.health = part->boids->health;
+ bpa->data.mode = eBoidMode_InAir;
+ bpa->data.state_id = ((BoidState*)part->boids->states.first)->id;
+ bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f;
}
@@ -1819,6 +1831,9 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->lifetime = 100.0f;
}
else{
+ /* get possible textural influence */
+ psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra);
+
pa->lifetime = part->lifetime * ptex.life;
if(part->randlife != 0.0f)
@@ -1904,6 +1919,7 @@ static void set_keyed_keys(ParticleSimulationData *sim)
PARTICLE_P;
ParticleKey *key;
int totpart = psys->totpart, k, totkeys = psys->totkeyed;
+ int keyed_flag = 0;
ksim.scene= sim->scene;
@@ -1933,6 +1949,8 @@ static void set_keyed_keys(ParticleSimulationData *sim)
for(k=0; k<totkeys; k++) {
ksim.ob = pt->ob ? pt->ob : sim->ob;
ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1);
+ keyed_flag = (ksim.psys->flag & PSYS_KEYED);
+ ksim.psys->flag &= ~PSYS_KEYED;
LOOP_PARTICLES {
key = pa->keys + k;
@@ -1956,6 +1974,8 @@ static void set_keyed_keys(ParticleSimulationData *sim)
if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f)
k++;
+ ksim.psys->flag |= keyed_flag;
+
pt = (pt->next && pt->next->flag & PTARGET_VALID)? pt->next : psys->targets.first;
}
@@ -3490,13 +3510,15 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
static void hair_step(ParticleSimulationData *sim, float cfra)
{
ParticleSystem *psys = sim->psys;
-/* ParticleSettings *part = psys->part; */
+ ParticleSettings *part = psys->part;
PARTICLE_P;
float disp = (float)psys_get_current_display_percentage(psys)/100.0f;
- BLI_srandom(psys->seed);
-
LOOP_PARTICLES {
+ pa->size = part->size;
+ if(part->randsize > 0.0f)
+ pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+
if(PSYS_FRAND(p) > disp)
pa->flag |= PARS_NO_DISP;
else
@@ -3650,7 +3672,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
birthtime = pa->time;
- dietime = birthtime + pa->lifetime;
+ dietime = pa->dietime;
/* store this, so we can do multiple loops over particles */
pa->state.time = dfra;
@@ -3781,8 +3803,6 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
PARTICLE_P;
float disp, dietime;
- BLI_srandom(psys->seed);
-
psys_update_effectors(sim);
disp= (float)psys_get_current_display_percentage(psys)/100.0f;
@@ -3967,7 +3987,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL);
/* clear everythin on start frame */
- if((int)cfra == startframe) {
+ if(cfra == startframe) {
BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED);
BKE_ptcache_validate(cache, startframe);
cache->flag &= ~PTCACHE_REDO_NEEDED;
@@ -4034,7 +4054,6 @@ static void system_step(ParticleSimulationData *sim, float cfra)
/* set particles to be not calculated TODO: can't work with pointcache */
disp= (float)psys_get_current_display_percentage(psys)/100.0f;
- BLI_srandom(psys->seed);
LOOP_PARTICLES {
if(PSYS_FRAND(p) > disp)
pa->flag |= PARS_NO_DISP;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 64893bb0b5b..b8f4b2d302f 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -516,6 +516,7 @@ static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra))
return clmd->clothObject ? clmd->clothObject->numverts : 0;
}
+#ifdef WITH_SMOKE
/* Smoke functions */
static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra))
{
@@ -652,6 +653,11 @@ static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v)
}
}
}
+#else // WITH_SMOKE
+static int ptcache_smoke_totpoint(void *UNUSED(smoke_v), int UNUSED(cfra)) { return 0; };
+static void ptcache_smoke_read(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) {}
+static int ptcache_smoke_write(PTCacheFile *UNUSED(pf), void *UNUSED(smoke_v)) { return 0; }
+#endif // WITH_SMOKE
/* Creating ID's */
void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
@@ -2124,7 +2130,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
{
Object *ob;
PointCache *cache;
- float offset, time, nexttime;
+ /* float offset; unused for now */
+ float time, nexttime;
/* TODO: this has to be sorter out once bsystem_time gets redone, */
/* now caches can handle interpolating etc. too - jahka */
@@ -2152,13 +2159,18 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra
*startframe= cache->startframe;
*endframe= cache->endframe;
- // XXX ipoflag is depreceated - old animation system stuff
- if (/*(ob->ipoflag & OB_OFFS_PARENT) &&*/ (ob->partype & PARSLOW)==0) {
+ /* TODO: time handling with object offsets and simulated vs. cached
+ * particles isn't particularly easy, so for now what you see is what
+ * you get. In the future point cache could handle the whole particle
+ * system timing. */
+#if 0
+ if ((ob->partype & PARSLOW)==0) {
offset= give_timeoffset(ob);
*startframe += (int)(offset+0.5f);
*endframe += (int)(offset+0.5f);
}
+#endif
}
/* verify cached_frames array is up to date */
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 16cef67ea6d..0d523599598 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -430,6 +430,7 @@ void init_actuator(bActuator *act)
act->data= MEM_callocN(sizeof(bCameraActuator), "camact");
ca = act->data;
ca->axis = ACT_CAMERA_X;
+ ca->damping = 1.0/32.0;
break;
case ACT_EDIT_OBJECT:
act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact");
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 791d572d385..51eaba3c05b 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -468,6 +468,7 @@ Scene *add_scene(const char *name)
sce->r.ffcodecdata.audio_mixrate = 44100;
sce->r.ffcodecdata.audio_volume = 1.0f;
+ sce->r.ffcodecdata.audio_bitrate = 192;
BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine));
@@ -475,8 +476,7 @@ Scene *add_scene(const char *name)
sce->audio.doppler_factor = 1.0;
sce->audio.speed_of_sound = 343.3;
- strcpy(sce->r.backbuf, "//backbuf");
- strcpy(sce->r.pic, U.renderdir);
+ BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic));
BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f);
sce->r.osa= 8;
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 63e35408381..50b3e32278a 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -31,6 +31,7 @@
* \ingroup bke
*/
+#include "BLI_winstuff.h"
#include <string.h>
#include <stdio.h>
@@ -416,3 +417,20 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene)
}
}
+/* magic zoom calculation, no idea what
+ * it signifies, if you find out, tell me! -zr
+ */
+
+/* simple, its magic dude!
+ * well, to be honest, this gives a natural feeling zooming
+ * with multiple keypad presses (ton)
+ */
+float BKE_screen_view3d_zoom_to_fac(float camzoom)
+{
+ return powf(((float)M_SQRT2 + camzoom/50.0f), 2.0f) / 4.0f;
+}
+
+float BKE_screen_view3d_zoom_from_fac(float zoomfac)
+{
+ return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f);
+}
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 6f49155c0fd..8c19b0c15c3 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1582,7 +1582,7 @@ typedef struct WipeZone {
static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo)
{
wipezone->flip = (wipe->angle < 0);
- wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/log(2.0f));
+ wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/M_LN2);
wipezone->xo = xo;
wipezone->yo = yo;
wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f));
@@ -2373,7 +2373,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height,
/* Blancmange (bmange@airdmhor.gen.nz) */
k = -1.0f/(2.0f*(float)M_PI*blur*blur);
- fval=0;
+
for (ix = 0;ix< halfWidth;ix++){
weight = (float)exp(k*(ix*ix));
filter[halfWidth - ix] = weight;
@@ -2859,6 +2859,83 @@ static struct ImBuf * do_multicam(
}
/* **********************************************************************
+ ADJUSTMENT
+ ********************************************************************** */
+
+/* no effect inputs for adjustment, we use give_ibuf_seq */
+static int num_inputs_adjustment(void)
+{
+ return 0;
+}
+
+static int early_out_adjustment(struct Sequence *UNUSED(seq), float UNUSED(facf0), float UNUSED(facf1))
+{
+ return -1;
+}
+
+static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq,
+ float cfra)
+{
+ Editing * ed;
+ ListBase * seqbasep;
+ struct ImBuf * i = 0;
+
+ ed = context.scene->ed;
+
+ seqbasep = seq_seqbase(&ed->seqbase, seq);
+
+ if (seq->machine > 0) {
+ i = give_ibuf_seqbase(context, cfra,
+ seq->machine - 1, seqbasep);
+ }
+
+ /* found nothing? so let's work the way up the metastrip stack, so
+ that it is possible to group a bunch of adjustment strips into
+ a metastrip and have that work on everything below the metastrip
+ */
+
+ if (!i) {
+ Sequence * meta;
+
+ meta = seq_metastrip(&ed->seqbase, NULL, seq);
+
+ if (meta) {
+ i = do_adjustment_impl(context, meta, cfra);
+ }
+ }
+
+ return i;
+}
+
+static struct ImBuf * do_adjustment(
+ SeqRenderData context, Sequence *seq, float cfra,
+ float UNUSED(facf0), float UNUSED(facf1),
+ struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2),
+ struct ImBuf *UNUSED(ibuf3))
+{
+ struct ImBuf * i = 0;
+ struct ImBuf * out;
+ Editing * ed;
+
+ ed = context.scene->ed;
+
+ if (!ed) {
+ return NULL;
+ }
+
+ i = do_adjustment_impl(context, seq, cfra);
+
+ if (input_have_to_preprocess(context, seq, cfra)) {
+ out = IMB_dupImBuf(i);
+ IMB_freeImBuf(i);
+ } else {
+ out = i;
+ }
+
+ return out;
+}
+
+/* **********************************************************************
SPEED
********************************************************************** */
static void init_speed_effect(Sequence *seq)
@@ -2944,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;
}
@@ -3256,6 +3338,11 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type)
rval.early_out = early_out_multicam;
rval.execute = do_multicam;
break;
+ case SEQ_ADJUSTMENT:
+ rval.num_inputs = num_inputs_adjustment;
+ rval.early_out = early_out_adjustment;
+ rval.execute = do_adjustment;
+ break;
}
return rval;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index e3639dd1c51..d6a152a5280 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -73,15 +73,24 @@
#include "BKE_context.h"
#include "BKE_sound.h"
-#include "AUD_C-API.h"
+
+#ifdef WITH_AUDASPACE
+# include "AUD_C-API.h"
+#endif
#ifdef WIN32
#define snprintf _snprintf
#endif
-/* **** XXX ******** */
-//static void waitcursor(int val) {}
-//static int blender_test_break() {return 0;}
+
+static ImBuf* seq_render_strip_stack(
+ SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown);
+
+static ImBuf * seq_render_strip(
+ SeqRenderData context, Sequence * seq, float cfra);
+
+static void seq_free_animdata(Scene *scene, Sequence *seq);
+
/* **** XXX ******** */
#define SELECT 1
@@ -177,8 +186,6 @@ void seq_free_strip(Strip *strip)
MEM_freeN(strip);
}
-static void seq_free_animdata(Scene *scene, Sequence *seq);
-
void seq_free_sequence(Scene *scene, Sequence *seq)
{
if(seq->strip) seq_free_strip(seq->strip);
@@ -191,6 +198,10 @@ void seq_free_sequence(Scene *scene, Sequence *seq)
sh.free(seq);
}
+ if(seq->sound) {
+ ((ID *)seq->sound)->us--;
+ }
+
/* clipboard has no scene and will never have a sound handle or be active */
if(scene) {
Editing *ed = scene->ed;
@@ -446,51 +457,6 @@ void seq_end(SeqIterator *iter)
* in metastrips!)
**********************************************************************
*/
-#if 0 /* UNUSED */
-static void do_seq_count(ListBase *seqbase, int *totseq)
-{
- Sequence *seq;
-
- seq= seqbase->first;
- while(seq) {
- (*totseq)++;
- if(seq->seqbase.first) do_seq_count(&seq->seqbase, totseq);
- seq= seq->next;
- }
-}
-
-static void do_build_seqar(ListBase *seqbase, Sequence ***seqar, int depth)
-{
- Sequence *seq;
-
- seq= seqbase->first;
- while(seq) {
- seq->depth= depth;
- if(seq->seqbase.first) do_build_seqar(&seq->seqbase, seqar, depth+1);
- **seqar= seq;
- (*seqar)++;
- seq= seq->next;
- }
-}
-
-static void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq)
-{
- Sequence **tseqar;
-
- *totseq= 0;
- do_seq_count(seqbase, totseq);
-
- if(*totseq==0) {
- *seqar= NULL;
- return;
- }
- *seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar");
- tseqar= *seqar;
-
- do_build_seqar(seqbase, seqar, 0);
- *seqar= tseqar;
-}
-#endif /* UNUSED */
static void do_seq_count_cb(ListBase *seqbase, int *totseq,
int (*test_func)(Sequence * seq))
@@ -624,8 +590,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);
}
@@ -720,6 +700,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
}
seq->strip->len = seq->len;
case SEQ_SOUND:
+#ifdef WITH_AUDASPACE
if(!seq->sound)
return;
seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS);
@@ -729,6 +710,9 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
seq->len = 0;
}
seq->strip->len = seq->len;
+#else
+ return;
+#endif
break;
case SEQ_SCENE:
{
@@ -916,6 +900,7 @@ static const char *give_seqname_by_type(int type)
case SEQ_TRANSFORM: return "Transform";
case SEQ_COLOR: return "Color";
case SEQ_MULTICAM: return "Multicam";
+ case SEQ_ADJUSTMENT: return "Adjustment";
case SEQ_SPEED: return "Speed";
default:
return NULL;
@@ -1013,16 +998,22 @@ static float give_stripelem_index(Sequence *seq, float cfra)
int sta = seq->start;
int end = seq->start+seq->len-1;
- if(seq->len == 0) return -1;
+ if (seq->type & SEQ_EFFECT) {
+ end = seq->enddisp;
+ }
+
+ if(end < sta) {
+ return -1;
+ }
if(seq->flag&SEQ_REVERSE_FRAMES) {
/*reverse frame in this sequence */
- if(cfra <= sta) nr= seq->len-1;
+ if(cfra <= sta) nr= end - sta;
else if(cfra >= end) nr= 0;
else nr= end - cfra;
} else {
if(cfra <= sta) nr= 0;
- else if(cfra >= end) nr= seq->len-1;
+ else if(cfra >= end) nr= end - sta;
else nr= cfra - sta;
}
@@ -1039,7 +1030,11 @@ StripElem *give_stripelem(Sequence *seq, int cfra)
{
StripElem *se= seq->strip->stripdata;
- if(seq->type != SEQ_MOVIE) { /* movie use the first */
+ if(seq->type == SEQ_IMAGE) { /* only
+ IMAGE strips use the whole array,
+ MOVIE strips use only
+ the first element, all other strips
+ don't use this... */
int nr = (int) give_stripelem_index(seq, cfra);
if (nr == -1 || se == NULL) return NULL;
@@ -1093,15 +1088,12 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se
}
if(evaluate_seq_frame_gen(seq_arr, seqbasep, cfra)) {
- if (b > 0) {
- if (seq_arr[b] == NULL) {
- return 0;
- }
- } else {
- for (b = MAXSEQ; b > 0; b--) {
- if (video_seq_is_rendered(seq_arr[b])) {
- break;
- }
+ if (b == 0) {
+ b = MAXSEQ;
+ }
+ for (; b > 0; b--) {
+ if (video_seq_is_rendered(seq_arr[b])) {
+ break;
}
}
}
@@ -2071,8 +2063,9 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
break;
}
case SEQ_EFFECT:
- {
- ibuf = seq_render_effect_strip_impl(context, seq, cfra);
+ {
+ ibuf = seq_render_effect_strip_impl(
+ context, seq, seq->start + nr);
break;
}
case SEQ_IMAGE:
@@ -2855,7 +2848,10 @@ void seq_tx_set_final_right(Sequence *seq, int val)
since they work a bit differently to normal image seq's (during transform) */
int seq_single_check(Sequence *seq)
{
- return (seq->len==1 && ELEM3(seq->type, SEQ_IMAGE, SEQ_COLOR, SEQ_MULTICAM));
+ return (seq->len==1 && (
+ seq->type == SEQ_IMAGE
+ || ((seq->type & SEQ_EFFECT) &&
+ get_sequence_effect_num_inputs(seq->type) == 0)));
}
/* check if the selected seq's reference unselected seq's */
@@ -3214,26 +3210,49 @@ ListBase *seq_seqbase(ListBase *seqbase, Sequence *seq)
return NULL;
}
-int seq_swap(Sequence *seq_a, Sequence *seq_b)
+Sequence *seq_metastrip(ListBase * seqbase, Sequence * meta, Sequence *seq)
+{
+ Sequence * iseq;
+
+ for(iseq = seqbase->first; iseq; iseq = iseq->next) {
+ Sequence * rval;
+
+ if (seq == iseq) {
+ return meta;
+ } else if(iseq->seqbase.first &&
+ (rval = seq_metastrip(&iseq->seqbase, iseq, seq))) {
+ return rval;
+ }
+ }
+
+ return NULL;
+}
+
+int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
{
char name[sizeof(seq_a->name)];
- if(seq_a->len != seq_b->len)
+ if(seq_a->len != seq_b->len) {
+ *error_str= "Strips must be the same length";
return 0;
+ }
/* type checking, could be more advanced but disalow sound vs non-sound copy */
if(seq_a->type != seq_b->type) {
if(seq_a->type == SEQ_SOUND || seq_b->type == SEQ_SOUND) {
+ *error_str= "Strips were not compatible";
return 0;
}
/* disallow effects to swap with non-effects strips */
if((seq_a->type & SEQ_EFFECT) != (seq_b->type & SEQ_EFFECT)) {
+ *error_str= "Strips were not compatible";
return 0;
}
if((seq_a->type & SEQ_EFFECT) && (seq_b->type & SEQ_EFFECT)) {
if(get_sequence_effect_num_inputs(seq_a->type) != get_sequence_effect_num_inputs(seq_b->type)) {
+ *error_str= "Strips must have the same number of inputs";
return 0;
}
}
@@ -3482,6 +3501,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
return seq;
}
+#ifdef WITH_AUDASPACE
Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
{
Scene *scene= CTX_data_scene(C); /* only for sound */
@@ -3523,7 +3543,8 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
strip->len = seq->len = ceil(info.length * FPS);
strip->us= 1;
- strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+ /* we only need 1 element to store the filename */
+ strip->stripdata= se= MEM_callocN(sizeof(StripElem), "stripelem");
BLI_split_dirfile(seq_load->path, strip->dir, se->name);
@@ -3538,6 +3559,15 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
return seq;
}
+#else // WITH_AUDASPACE
+Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
+{
+ (void)C;
+ (void)seqbasep;
+ (void)seq_load;
+ return NULL;
+}
+#endif // WITH_AUDASPACE
Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load)
{
@@ -3572,7 +3602,8 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
strip->len = seq->len = IMB_anim_get_duration( an );
strip->us= 1;
- strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
+ /* we only need 1 element for MOVIE strips */
+ strip->stripdata= se= MEM_callocN(sizeof(StripElem), "stripelem");
BLI_split_dirfile(seq_load->path, strip->dir, se->name);
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 5b6c6bf8732..7b04a72666d 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -562,7 +562,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM
ssmd.subdivType = ME_CC_SUBSURF; //catmull clark
ssmd.levels = smd->subsurfLevels; //levels
- ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0);
+ ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT));
if(ss_mesh)
{
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
index ec0f5d1316b..4cc5a880625 100644
--- a/source/blender/blenkernel/intern/sketch.c
+++ b/source/blender/blenkernel/intern/sketch.c
@@ -543,7 +543,7 @@ int sk_stroke_filtermval(SK_DrawData *dd)
return retval;
}
-void sk_initDrawData(SK_DrawData *dd, const short mval[2])
+void sk_initDrawData(SK_DrawData *dd, const int mval[2])
{
dd->mval[0] = mval[0];
dd->mval[1] = mval[1];
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 4405bce3d51..6ab1574ca80 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -140,6 +140,19 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs)
#define TRI_UVOFFSET (1./4.)
+/* Stubs to use when smoke is disabled */
+#ifndef WITH_SMOKE
+struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype)) { return NULL; }
+struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(p0)) { return NULL; }
+void smoke_free(struct FLUID_3D *UNUSED(fluid)) {}
+void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {}
+void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(strength)) {}
+void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity), int *UNUSED(border_colli)) {}
+long long smoke_get_mem_req(int UNUSED(xres), int UNUSED(yres), int UNUSED(zres), int UNUSED(amplify)) { return 0; }
+void smokeModifier_do(SmokeModifierData *UNUSED(smd), Scene *UNUSED(scene), Object *UNUSED(ob), DerivedMesh *UNUSED(dm)) {}
+#endif // WITH_SMOKE
+
+
static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm)
{
if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid)
@@ -805,6 +818,9 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData
// forward decleration
static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct);
static float calc_voxel_transp(float *result, float *input, int res[3], int *pixel, float *tRay, float correct);
+
+#ifdef WITH_SMOKE
+
static int get_lamp(Scene *scene, float *light)
{
Base *base_tmp = NULL;
@@ -1646,3 +1662,4 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
}
}
+#endif // WITH_SMOKE
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 30d2816769c..2960d8a41e5 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -75,6 +75,7 @@ variables on the UI for now
#include "BKE_curve.h"
#include "BKE_effect.h"
#include "BKE_global.h"
+#include "BKE_modifier.h"
#include "BKE_softbody.h"
#include "BKE_DerivedMesh.h"
#include "BKE_pointcache.h"
@@ -289,21 +290,24 @@ typedef struct ccd_Mesh {
-static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
+static ccd_Mesh *ccd_mesh_make(Object *ob)
{
+ CollisionModifierData *cmd;
ccd_Mesh *pccd_M = NULL;
ccdf_minmax *mima =NULL;
MFace *mface=NULL;
float v[3],hull;
int i;
+ cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
+
/* first some paranoia checks */
- if (!dm) return NULL;
- if (!dm->getNumVerts(dm) || !dm->getNumFaces(dm)) return NULL;
+ if (!cmd) return NULL;
+ if (!cmd->numverts || !cmd->numfaces) return NULL;
pccd_M = MEM_mallocN(sizeof(ccd_Mesh),"ccd_Mesh");
- pccd_M->totvert = dm->getNumVerts(dm);
- pccd_M->totface = dm->getNumFaces(dm);
+ pccd_M->totvert = cmd->numverts;
+ pccd_M->totface = cmd->numfaces;
pccd_M->savety = CCD_SAVETY;
pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
@@ -314,12 +318,10 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
hull = MAX2(ob->pd->pdef_sbift,ob->pd->pdef_sboft);
/* alloc and copy verts*/
- pccd_M->mvert = dm->dupVertArray(dm);
- /* ah yeah, put the verices to global coords once */
- /* and determine the ortho BB on the fly */
+ pccd_M->mvert = MEM_dupallocN(cmd->xnew);
+ /* note that xnew coords are already in global space, */
+ /* determine the ortho BB */
for(i=0; i < pccd_M->totvert; i++){
- mul_m4_v3(ob->obmat, pccd_M->mvert[i].co);
-
/* evaluate limits */
VECCOPY(v,pccd_M->mvert[i].co);
pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull);
@@ -332,7 +334,7 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
}
/* alloc and copy faces*/
- pccd_M->mface = dm->dupFaceArray(dm);
+ pccd_M->mface = MEM_dupallocN(cmd->mfaces);
/* OBBs for idea1 */
pccd_M->mima = MEM_mallocN(sizeof(ccdf_minmax)*pccd_M->totface,"ccd_Mesh_Faces_mima");
@@ -386,19 +388,22 @@ static ccd_Mesh *ccd_mesh_make(Object *ob, DerivedMesh *dm)
}
return pccd_M;
}
-static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm)
+static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M)
{
- ccdf_minmax *mima =NULL;
+ CollisionModifierData *cmd;
+ ccdf_minmax *mima =NULL;
MFace *mface=NULL;
float v[3],hull;
int i;
+ cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision);
+
/* first some paranoia checks */
- if (!dm) return ;
- if (!dm->getNumVerts(dm) || !dm->getNumFaces(dm)) return ;
+ if (!cmd) return ;
+ if (!cmd->numverts || !cmd->numfaces) return ;
- if ((pccd_M->totvert != dm->getNumVerts(dm)) ||
- (pccd_M->totface != dm->getNumFaces(dm))) return;
+ if ((pccd_M->totvert != cmd->numverts) ||
+ (pccd_M->totface != cmd->numfaces)) return;
pccd_M->bbmin[0]=pccd_M->bbmin[1]=pccd_M->bbmin[2]=1e30f;
pccd_M->bbmax[0]=pccd_M->bbmax[1]=pccd_M->bbmax[2]=-1e30f;
@@ -411,12 +416,10 @@ static void ccd_mesh_update(Object *ob,ccd_Mesh *pccd_M, DerivedMesh *dm)
if(pccd_M->mprevvert) MEM_freeN(pccd_M->mprevvert);
pccd_M->mprevvert = pccd_M->mvert;
/* alloc and copy verts*/
- pccd_M->mvert = dm->dupVertArray(dm);
- /* ah yeah, put the verices to global coords once */
- /* and determine the ortho BB on the fly */
+ pccd_M->mvert = MEM_dupallocN(cmd->xnew);
+ /* note that xnew coords are already in global space, */
+ /* determine the ortho BB */
for(i=0; i < pccd_M->totvert; i++){
- mul_m4_v3(ob->obmat, pccd_M->mvert[i].co);
-
/* evaluate limits */
VECCOPY(v,pccd_M->mvert[i].co);
pccd_M->bbmin[0] = MIN2(pccd_M->bbmin[0],v[0]-hull);
@@ -555,21 +558,8 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h
/*+++ only with deflecting set */
if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == NULL) {
- DerivedMesh *dm= NULL;
-
- if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- else
- dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
-
- if(dm){
- ccd_Mesh *ccdmesh = ccd_mesh_make(ob, dm);
- BLI_ghash_insert(hash, ob, ccdmesh);
-
- /* we did copy & modify all we need so give 'em away again */
- dm->release(dm);
-
- }
+ ccd_Mesh *ccdmesh = ccd_mesh_make(ob);
+ BLI_ghash_insert(hash, ob, ccdmesh);
}/*--- only with deflecting set */
}/* mesh && layer*/
@@ -595,21 +585,9 @@ static void ccd_update_deflector_hash(Scene *scene, Object *vertexowner, GHash *
/*+++ only with deflecting set */
if(ob->pd && ob->pd->deflect) {
- DerivedMesh *dm= NULL;
-
- if(ob->softflag & OB_SB_COLLFINAL) { /* so maybe someone wants overkill to collide with subsurfed */
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- } else {
- dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);
- }
- if(dm){
- ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob);
- if (ccdmesh)
- ccd_mesh_update(ob,ccdmesh,dm);
-
- /* we did copy & modify all we need so give 'em away again */
- dm->release(dm);
- }
+ ccd_Mesh *ccdmesh = BLI_ghash_lookup(hash,ob);
+ if (ccdmesh)
+ ccd_mesh_update(ob,ccdmesh);
}/*--- only with deflecting set */
}/* mesh && layer*/
@@ -640,7 +618,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
{
Mesh *me= ob->data;
MFace *mface= me->mface;
- BodyPoint *bp;
+ /*BodyPoint *bp;*/ /*UNUSED*/
BodySpring *bs, *bs_new;
int a ;
@@ -661,7 +639,7 @@ static void add_mesh_quad_diag_springs(Object *ob)
/* fill the tail */
a = 0;
bs = bs_new+ob->soft->totspring;
- bp= ob->soft->bpoint;
+ /*bp= ob->soft->bpoint; */ /*UNUSED*/
if(mface ) {
for(a=me->totface; a>0; a--, mface++) {
if(mface->v4) {
@@ -1042,7 +1020,10 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int
GHash *hash;
GHashIterator *ihash;
float aabbmin[3],aabbmax[3];
- int a, deflected=0;
+ int deflected=0;
+#if 0
+ int a;
+#endif
if ((sb == NULL) || (sb->scratch ==NULL)) return 0;
VECCOPY(aabbmin,sb->scratch->aabbmin);
@@ -1056,17 +1037,20 @@ static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int
ob = BLI_ghashIterator_getKey (ihash);
/* only with deflecting set */
if(ob->pd && ob->pd->deflect) {
+#if 0 /* UNUSED */
MFace *mface= NULL;
MVert *mvert= NULL;
MVert *mprevvert= NULL;
ccdf_minmax *mima= NULL;
+#endif
if(ccdm){
+#if 0 /* UNUSED */
mface= ccdm->mface;
mvert= ccdm->mvert;
mprevvert= ccdm->mprevvert;
mima= ccdm->mima;
a = ccdm->totface;
-
+#endif
if ((aabbmax[0] < ccdm->bbmin[0]) ||
(aabbmax[1] < ccdm->bbmin[1]) ||
(aabbmax[2] < ccdm->bbmin[2]) ||
@@ -2095,19 +2079,25 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN
float dir[3],dvel[3];
float distance,forcefactor,kd,absvel,projvel,kw;
+#if 0 /* UNUSED */
int ia,ic;
+#endif
/* prepare depending on which side of the spring we are on */
if (bpi == bs->v1){
bp1 = &sb->bpoint[bs->v1];
bp2 = &sb->bpoint[bs->v2];
+#if 0 /* UNUSED */
ia =3*bs->v1;
ic =3*bs->v2;
+#endif
}
else if (bpi == bs->v2){
bp1 = &sb->bpoint[bs->v2];
bp2 = &sb->bpoint[bs->v1];
+#if 0 /* UNUSED */
ia =3*bs->v2;
ic =3*bs->v1;
+#endif
}
else{
/* TODO make this debug option */
@@ -2454,23 +2444,23 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl
* this will ruin adaptive stepsize AKA heun! (BM)
*/
SoftBody *sb= ob->soft; /* is supposed to be there */
- BodyPoint *bproot;
+ /*BodyPoint *bproot;*/ /* UNUSED */
ListBase *do_effector = NULL;
- float gravity;
+ /* float gravity; */ /* UNUSED */
/* float iks; */
float fieldfactor = -1.0f, windfactor = 0.25;
- int do_deflector,do_selfcollision,do_springcollision,do_aero;
+ int do_deflector /*,do_selfcollision*/ ,do_springcollision,do_aero;
- gravity = sb->grav * sb_grav_force_scale(ob);
+ /* gravity = sb->grav * sb_grav_force_scale(ob); */ /* UNUSED */
/* check conditions for various options */
do_deflector= query_external_colliders(scene, ob);
- do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF));
+ /* do_selfcollision=((ob->softflag & OB_SB_EDGES) && (sb->bspring)&& (ob->softflag & OB_SB_SELF)); */ /* UNUSED */
do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL);
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
/* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */
- bproot= sb->bpoint; /* need this for proper spring addressing */
+ /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
if (do_springcollision || do_aero)
sb_sfesf_threads_run(scene, ob, timenow,sb->totspring,NULL);
@@ -2516,7 +2506,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
*/
SoftBody *sb= ob->soft; /* is supposed to be there */
BodyPoint *bp;
- BodyPoint *bproot;
+ /* BodyPoint *bproot; */ /* UNUSED */
BodySpring *bs;
ListBase *do_effector = NULL;
float iks, ks, kd, gravity[3] = {0.0f,0.0f,0.0f};
@@ -2547,7 +2537,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa
do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES));
iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */
- bproot= sb->bpoint; /* need this for proper spring addressing */
+ /* bproot= sb->bpoint; */ /* need this for proper spring addressing */ /* UNUSED */
if (do_springcollision || do_aero) scan_for_ext_spring_forces(scene, ob, timenow);
/* after spring scan because it uses Effoctors too */
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index e0e456a371e..1c61646a3d8 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -21,7 +21,9 @@
#include "DNA_screen_types.h"
#include "DNA_sound_types.h"
-#include "AUD_C-API.h"
+#ifdef WITH_AUDASPACE
+# include "AUD_C-API.h"
+#endif
#include "BKE_utildefines.h"
#include "BKE_global.h"
@@ -34,6 +36,61 @@
#include "BKE_animsys.h"
+struct bSound* sound_new_file(struct Main *bmain, const char *filename)
+{
+ bSound* sound = NULL;
+
+ char str[FILE_MAX];
+ char *path;
+
+ int len;
+
+ strcpy(str, filename);
+
+ path = /*bmain ? bmain->name :*/ G.main->name;
+
+ BLI_path_abs(str, path);
+
+ len = strlen(filename);
+ while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
+ len--;
+
+ sound = alloc_libblock(&bmain->sound, ID_SO, filename+len);
+ BLI_strncpy(sound->name, filename, FILE_MAX);
+// XXX unused currently sound->type = SOUND_TYPE_FILE;
+
+ sound_load(bmain, sound);
+
+ if(!sound->playback_handle)
+ {
+ free_libblock(&bmain->sound, sound);
+ sound = NULL;
+ }
+
+ return sound;
+}
+
+void sound_free(struct bSound* sound)
+{
+ if (sound->packedfile)
+ {
+ freePackedFile(sound->packedfile);
+ sound->packedfile = NULL;
+ }
+
+#ifdef WITH_AUDASPACE
+ if(sound->handle)
+ {
+ AUD_unload(sound->handle);
+ sound->handle = NULL;
+ sound->playback_handle = NULL;
+ }
+#endif // WITH_AUDASPACE
+}
+
+
+#ifdef WITH_AUDASPACE
+
static int force_device = -1;
#ifdef WITH_JACK
@@ -123,40 +180,6 @@ void sound_exit(void)
AUD_exit();
}
-struct bSound* sound_new_file(struct Main *bmain, const char *filename)
-{
- bSound* sound = NULL;
-
- char str[FILE_MAX];
- char *path;
-
- int len;
-
- strcpy(str, filename);
-
- path = /*bmain ? bmain->name :*/ G.main->name;
-
- BLI_path_abs(str, path);
-
- len = strlen(filename);
- while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\')
- len--;
-
- sound = alloc_libblock(&bmain->sound, ID_SO, filename+len);
- BLI_strncpy(sound->name, filename, FILE_MAX);
-// XXX unused currently sound->type = SOUND_TYPE_FILE;
-
- sound_load(bmain, sound);
-
- if(!sound->playback_handle)
- {
- free_libblock(&bmain->sound, sound);
- sound = NULL;
- }
-
- return sound;
-}
-
// XXX unused currently
#if 0
struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source)
@@ -301,22 +324,6 @@ void sound_load(struct Main *bmain, struct bSound* sound)
}
}
-void sound_free(struct bSound* sound)
-{
- if (sound->packedfile)
- {
- freePackedFile(sound->packedfile);
- sound->packedfile = NULL;
- }
-
- if(sound->handle)
- {
- AUD_unload(sound->handle);
- sound->handle = NULL;
- sound->playback_handle = NULL;
- }
-}
-
static float sound_get_volume(Scene* scene, Sequence* sequence, float time)
{
AnimData *adt= BKE_animdata_from_id(&scene->id);
@@ -490,8 +497,9 @@ int sound_scene_playing(struct Scene *scene)
int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, float start, float end)
{
AUD_Sound* limiter = AUD_limitSound(sound->cache, start, end);
- return AUD_readSound(limiter, buffer, length);
+ int ret= AUD_readSound(limiter, buffer, length);
AUD_unload(limiter);
+ return ret;
}
int sound_get_channels(struct bSound* sound)
@@ -502,3 +510,34 @@ int sound_get_channels(struct bSound* sound)
return info.specs.channels;
}
+
+#else // WITH_AUDASPACE
+
+#include "BLI_utildefines.h"
+
+int sound_define_from_str(const char *UNUSED(str)) { return -1;}
+void sound_force_device(int UNUSED(device)) {}
+void sound_init_once(void) {}
+void sound_init(struct Main *UNUSED(bmain)) {}
+void sound_exit(void) {}
+void sound_cache(struct bSound* UNUSED(sound), int UNUSED(ignore)) { }
+void sound_delete_cache(struct bSound* UNUSED(sound)) {}
+void sound_load(struct Main *UNUSED(bmain), struct bSound* UNUSED(sound)) {}
+void sound_create_scene(struct Scene *UNUSED(scene)) {}
+void sound_destroy_scene(struct Scene *UNUSED(scene)) {}
+void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
+void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {}
+void sound_mute_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), char UNUSED(mute)) {}
+void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
+static void sound_start_play_scene(struct Scene *UNUSED(scene)) {}
+void sound_play_scene(struct Scene *UNUSED(scene)) {}
+void sound_stop_scene(struct Scene *UNUSED(scene)) {}
+void sound_seek_scene(struct bContext *UNUSED(C)) {}
+float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; }
+int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
+int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
+int sound_get_channels(struct bSound* UNUSED(sound)) { return 1; }
+
+#endif // WITH_AUDASPACE
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 5d44841df8b..67d7e7bffd6 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1176,7 +1176,8 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
CCGSubSurf *ss = ccgdm->ss;
CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss);
CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
- int i, edgeSize = ccgSubSurf_getEdgeSize(ss);
+ int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss);
+ int totedge = ccgSubSurf_getNumEdges(ss);
int gridSize = ccgSubSurf_getGridSize(ss);
int useAging;
@@ -1184,13 +1185,16 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw
ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL);
- for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) {
- CCGEdge *e = ccgEdgeIterator_getCurrent(ei);
+ for (j=0; j< totedge; j++) {
+ CCGEdge *e = ccgdm->edgeMap[j].edge;
DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e);
if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e))
continue;
+ if(ccgdm->edgeFlags && !(ccgdm->edgeFlags[j] & ME_EDGEDRAW))
+ continue;
+
if (useAging && !(G.f&G_BACKBUFSEL)) {
int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4;
glColor3ub(0, ageCol>0?ageCol:0, 0);
@@ -2617,7 +2621,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
struct DerivedMesh *dm,
struct SubsurfModifierData *smd,
int useRenderParams, float (*vertCos)[3],
- int isFinalCalc, int editMode)
+ int isFinalCalc, int forEditMode, int inEditMode)
{
int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF;
int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr;
@@ -2625,7 +2629,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges);
CCGDerivedMesh *result;
- if(editMode) {
+ if(forEditMode) {
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
smd->emCache = _getSubSurf(smd->emCache, levels, useAging, 0,
@@ -2656,7 +2660,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
int useAging = smd->flags & eSubsurfModifierFlag_DebugIncr;
int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels;
CCGSubSurf *ss;
-
+
/* It is quite possible there is a much better place to do this. It
* depends a bit on how rigourously we expect this function to never
* be called in editmode. In semi-theory we could share a single
@@ -2664,8 +2668,11 @@ struct DerivedMesh *subsurf_make_derived_from_derived(
* the same so we would need some way of converting them. Its probably
* not worth the effort. But then why am I even writing this long
* comment that no one will read? Hmmm. - zr
+ *
+ * Addendum: we can't really ensure that this is never called in edit
+ * mode, so now we have a parameter to verify it. - brecht
*/
- if(smd->emCache) {
+ if(!inEditMode && smd->emCache) {
ccgSubSurf_free(smd->emCache);
smd->emCache = NULL;
}
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index ba5d4282416..2c507370288 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -238,7 +238,7 @@ static void cleanup_textline(TextLine * tl)
int reopen_text(Text *text)
{
FILE *fp;
- int i, llen, len, res;
+ int i, llen, len;
unsigned char *buffer;
TextLine *tmp;
char str[FILE_MAXDIR+FILE_MAXFILE];
@@ -281,7 +281,7 @@ int reopen_text(Text *text)
fclose(fp);
- res= stat(str, &st);
+ stat(str, &st);
text->mtime= st.st_mtime;
text->nlines=0;
@@ -334,7 +334,7 @@ Text *add_text(const char *file, const char *relpath)
{
Main *bmain= G.main;
FILE *fp;
- int i, llen, len, res;
+ int i, llen, len;
unsigned char *buffer;
TextLine *tmp;
Text *ta;
@@ -374,7 +374,7 @@ Text *add_text(const char *file, const char *relpath)
fclose(fp);
- res= stat(str, &st);
+ stat(str, &st);
ta->mtime= st.st_mtime;
ta->nlines=0;
@@ -400,7 +400,13 @@ Text *add_text(const char *file, const char *relpath)
llen++;
}
- if (llen!=0 || ta->nlines==0) {
+ /* create new line in cases:
+ - rest of line (if last line in file hasn't got \n terminator).
+ in this case content of such line would be used to fill text line buffer
+ - file is empty. in this case new line is needed to start editing from.
+ - last characted in buffer is \n. in this case new line is needed to
+ deal with newline at end of file. (see [#28087]) (sergey) */
+ if (llen!=0 || ta->nlines==0 || buffer[len-1]=='\n') {
tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line= (char*) MEM_mallocN(llen+1, "textline_string");
tmp->format= NULL;
@@ -1232,21 +1238,19 @@ char *txt_to_buf (Text *text)
return buf;
}
-int txt_find_string(Text *text, char *findstr, int wrap)
+int txt_find_string(Text *text, char *findstr, int wrap, int match_case)
{
TextLine *tl, *startl;
char *s= NULL;
- int oldcl, oldsl;
if (!text || !text->curl || !text->sell) return 0;
txt_order_cursors(text);
- oldcl= txt_get_span(text->lines.first, text->curl);
- oldsl= txt_get_span(text->lines.first, text->sell);
tl= startl= text->sell;
- s= strstr(&tl->line[text->selc], findstr);
+ if(match_case) s= strstr(&tl->line[text->selc], findstr);
+ else s= BLI_strcasestr(&tl->line[text->selc], findstr);
while (!s) {
tl= tl->next;
if (!tl) {
@@ -1256,7 +1260,8 @@ int txt_find_string(Text *text, char *findstr, int wrap)
break;
}
- s= strstr(tl->line, findstr);
+ if(match_case) s= strstr(tl->line, findstr);
+ else s= BLI_strcasestr(tl->line, findstr);
if (tl==startl)
break;
}
@@ -1418,6 +1423,8 @@ void txt_insert_buf(Text *text, const char *in_buffer)
}
undoing= u;
+
+ (void)count;
}
/******************/
@@ -1892,13 +1899,13 @@ void txt_do_undo(Text *text)
if (op==UNDO_INDENT) {
- unindent(text);
+ txt_unindent(text);
} else if (op== UNDO_UNINDENT) {
- indent(text);
+ txt_indent(text);
} else if (op == UNDO_COMMENT) {
- uncomment(text);
+ txt_uncomment(text);
} else if (op == UNDO_UNCOMMENT) {
- comment(text);
+ txt_comment(text);
}
text->undo_pos--;
@@ -2108,13 +2115,13 @@ void txt_do_redo(Text *text)
}
if (op==UNDO_INDENT) {
- indent(text);
+ txt_indent(text);
} else if (op== UNDO_UNINDENT) {
- unindent(text);
+ txt_unindent(text);
} else if (op == UNDO_COMMENT) {
- comment(text);
+ txt_comment(text);
} else if (op == UNDO_UNCOMMENT) {
- uncomment(text);
+ txt_uncomment(text);
}
break;
default:
@@ -2412,7 +2419,7 @@ static int txt_add_char_intern (Text *text, char add, int replace_tabs)
return 1;
}
- /* insert spaces rather then tabs */
+ /* insert spaces rather than tabs */
if (add == '\t' && replace_tabs) {
txt_convert_tab_to_spaces(text);
return 1;
@@ -2499,7 +2506,7 @@ int txt_replace_char (Text *text, char add)
return 1;
}
-void indent(Text *text)
+void txt_indent(Text *text)
{
int len, num;
char *tmp;
@@ -2510,7 +2517,7 @@ void indent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
- /* insert spaces rather then tabs */
+ /* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES){
add = tab_to_spaces;
indentlen = spaceslen;
@@ -2562,7 +2569,7 @@ void indent(Text *text)
}
}
-void unindent(Text *text)
+void txt_unindent(Text *text)
{
int num = 0;
const char *remove = "\t";
@@ -2571,7 +2578,7 @@ void unindent(Text *text)
/* hardcoded: TXT_TABSIZE = 4 spaces: */
int spaceslen = TXT_TABSIZE;
- /* insert spaces rather then tabs */
+ /* insert spaces rather than tabs */
if (text->flags & TXT_TABSTOSPACES){
remove = tab_to_spaces;
indent = spaceslen;
@@ -2620,7 +2627,7 @@ void unindent(Text *text)
}
}
-void comment(Text *text)
+void txt_comment(Text *text)
{
int len, num;
char *tmp;
@@ -2672,7 +2679,7 @@ void comment(Text *text)
}
}
-void uncomment(Text *text)
+void txt_uncomment(Text *text)
{
int num = 0;
char remove = '#';
@@ -2749,19 +2756,19 @@ int setcurr_tab_spaces (Text *text, int space)
* 2) within an identifier
* 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414]
*/
- int a, indent = 0;
+ int a, is_indent = 0;
for(a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++)
{
char ch= text->curl->line[a];
if (ch=='#') {
break;
} else if (ch==':') {
- indent = 1;
- } else if (ch==']' || ch=='}' || ch=='"' || ch=='\'') {
- indent = 0;
+ is_indent = 1;
+ } else if (ch!=' ' && ch!='\t') {
+ is_indent = 0;
}
}
- if (indent) {
+ if (is_indent) {
i += space;
}
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 9cd07de31dc..036ba34d0c8 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -1191,6 +1191,28 @@ void set_current_material_texture(Material *ma, Tex *newtex)
}
}
+int has_current_material_texture(Material *ma)
+{
+ bNode *node;
+
+ if(ma && ma->use_nodes && ma->nodetree) {
+ node= nodeGetActiveID(ma->nodetree, ID_TE);
+
+ if(node) {
+ return 1;
+ }
+ else {
+ node= nodeGetActiveID(ma->nodetree, ID_MA);
+ if(node)
+ ma= (Material*)node->id;
+ else
+ ma= NULL;
+ }
+ }
+
+ return (ma != NULL);
+}
+
Tex *give_current_world_texture(World *world)
{
MTex *mtex= NULL;
@@ -1464,6 +1486,10 @@ int BKE_texture_dependsOnTime(const struct Tex *texture)
// assume anything in adt means the texture is animated
return 1;
}
+ else if(texture->type == TEX_NOISE) {
+ // noise always varies with time
+ return 1;
+ }
return 0;
}
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 7a76e61c17b..d413177873f 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -43,6 +43,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
+#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BKE_world.h"
@@ -117,17 +118,36 @@ World *copy_world(World *wrld)
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a]) {
- wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial");
+ wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copy_world");
memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
id_us_plus((ID *)wrldn->mtex[a]->tex);
}
}
- if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview);
+ if(wrld->preview)
+ wrldn->preview = BKE_previewimg_copy(wrld->preview);
-#if 0 // XXX old animation system
- id_us_plus((ID *)wrldn->ipo);
-#endif // XXX old animation system
+ return wrldn;
+}
+
+World *localize_world(World *wrld)
+{
+ World *wrldn;
+ int a;
+
+ wrldn= copy_libblock(wrld);
+ BLI_remlink(&G.main->world, wrldn);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(wrld->mtex[a]) {
+ wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world");
+ memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex));
+ /* free world decrements */
+ id_us_plus((ID *)wrldn->mtex[a]->tex);
+ }
+ }
+
+ wrldn->preview= NULL;
return wrldn;
}
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index ba7f9bdd415..769a3f9b11e 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -105,13 +105,18 @@ bMovieHandle *BKE_get_movie_handle(int imtype)
mh.get_movie_path = filepath_ffmpeg;
}
#endif
+#ifdef WITH_FRAMESERVER
if (imtype == R_FRAMESERVER) {
mh.start_movie = start_frameserver;
mh.append_movie = append_frameserver;
mh.end_movie = end_frameserver;
mh.get_next_frame = frameserver_loop;
}
-
+#endif
+
+ /* incase all above are disabled */
+ (void)imtype;
+
return &mh;
}
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 9b1c3b2ddb8..4db53999f10 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -39,19 +39,6 @@
#include <libswscale/swscale.h>
#include <libavcodec/opt.h>
-#if LIBAVFORMAT_VERSION_INT < (49 << 16)
-#define FFMPEG_OLD_FRAME_RATE 1
-#else
-#define FFMPEG_CODEC_IS_POINTER 1
-#define FFMPEG_CODEC_TIME_BASE 1
-#endif
-
-#if LIBAVFORMAT_VERSION_INT >= (52 << 16)
-#define OUTFILE_PB (outfile->pb)
-#else
-#define OUTFILE_PB (&outfile->pb)
-#endif
-
#if defined(WIN32) && (!(defined snprintf))
#define snprintf _snprintf
#endif
@@ -62,7 +49,9 @@
#include "BLI_blenlib.h"
-#include "AUD_C-API.h" /* must be before BKE_sound.h for define */
+#ifdef WITH_AUDASPACE
+# include "AUD_C-API.h"
+#endif
#include "BKE_global.h"
#include "BKE_idprop.h"
@@ -74,6 +63,8 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
+#include "ffmpeg_compat.h"
+
extern void do_init_ffmpeg(void);
static int ffmpeg_type = 0;
@@ -100,7 +91,9 @@ static uint8_t* audio_output_buffer = 0;
static int audio_outbuf_size = 0;
static double audio_time = 0.0f;
+#ifdef WITH_AUDASPACE
static AUD_Device* audio_mixdown_device = 0;
+#endif
#define FFMPEG_AUTOSPLIT_SIZE 2000000000
@@ -114,24 +107,13 @@ static void delete_picture(AVFrame* f)
}
}
-#ifdef FFMPEG_CODEC_IS_POINTER
-static AVCodecContext* get_codec_from_stream(AVStream* stream)
-{
- return stream->codec;
-}
-#else
-static AVCodecContext* get_codec_from_stream(AVStream* stream)
-{
- return &stream->codec;
-}
-#endif
-
+#ifdef WITH_AUDASPACE
static int write_audio_frame(void)
{
AVCodecContext* c = NULL;
AVPacket pkt;
- c = get_codec_from_stream(audio_stream);
+ c = audio_stream->codec;
av_init_packet(&pkt);
pkt.size = 0;
@@ -153,23 +135,22 @@ static int write_audio_frame(void)
if(c->coded_frame && c->coded_frame->pts != AV_NOPTS_VALUE)
{
-#ifdef FFMPEG_CODEC_TIME_BASE
pkt.pts = av_rescale_q(c->coded_frame->pts,
- c->time_base, audio_stream->time_base);
-#else
- pkt.pts = c->coded_frame->pts;
-#endif
+ c->time_base, audio_stream->time_base);
fprintf(stderr, "Audio Frame PTS: %d\n", (int)pkt.pts);
}
pkt.stream_index = audio_stream->index;
- pkt.flags |= PKT_FLAG_KEY;
+
+ pkt.flags |= AV_PKT_FLAG_KEY;
+
if (av_interleaved_write_frame(outfile, &pkt) != 0) {
fprintf(stderr, "Error writing audio packet!\n");
return -1;
}
return 0;
}
+#endif // #ifdef WITH_AUDASPACE
/* Allocate a temporary frame */
static AVFrame* alloc_picture(int pix_fmt, int width, int height)
@@ -263,10 +244,10 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports
{
int outsize = 0;
int ret, success= 1;
- AVCodecContext* c = get_codec_from_stream(video_stream);
-#ifdef FFMPEG_CODEC_TIME_BASE
+ AVCodecContext* c = video_stream->codec;
+
frame->pts = rd->cfra - rd->sfra;
-#endif
+
if (rd->mode & R_FIELDS) {
frame->top_field_first = ((rd->mode & R_ODDFIELD) != 0);
}
@@ -278,19 +259,15 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports
av_init_packet(&packet);
if (c->coded_frame->pts != AV_NOPTS_VALUE) {
-#ifdef FFMPEG_CODEC_TIME_BASE
packet.pts = av_rescale_q(c->coded_frame->pts,
c->time_base,
video_stream->time_base);
-#else
- packet.pts = c->coded_frame->pts;
-#endif
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
} else {
fprintf(stderr, "Video Frame PTS: not set\n");
}
if (c->coded_frame->key_frame)
- packet.flags |= PKT_FLAG_KEY;
+ packet.flags |= AV_PKT_FLAG_KEY;
packet.stream_index = video_stream->index;
packet.data = video_buffer;
packet.size = outsize;
@@ -312,7 +289,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports)
{
uint8_t* rendered_frame;
- AVCodecContext* c = get_codec_from_stream(video_stream);
+ AVCodecContext* c = video_stream->codec;
int width = c->width;
int height = c->height;
AVFrame* rgb_frame;
@@ -396,7 +373,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
switch(prop->type) {
case IDP_STRING:
fprintf(stderr, "%s.\n", IDP_String(prop));
- rv = av_set_string(c, prop->name, IDP_String(prop));
+ av_set_string3(c, prop->name, IDP_String(prop), 1, &rv);
break;
case IDP_FLOAT:
fprintf(stderr, "%g.\n", IDP_Float(prop));
@@ -407,7 +384,7 @@ static void set_ffmpeg_property_option(AVCodecContext* c, IDProperty * prop)
if (param) {
if (IDP_Int(prop)) {
- rv = av_set_string(c, name, param);
+ av_set_string3(c, name, param, 1, &rv);
} else {
return;
}
@@ -459,9 +436,9 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
/* Set up the codec context */
- c = get_codec_from_stream(st);
+ c = st->codec;
c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_VIDEO;
+ c->codec_type = AVMEDIA_TYPE_VIDEO;
/* Get some values from the current render settings */
@@ -469,7 +446,6 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->width = rectx;
c->height = recty;
-#ifdef FFMPEG_CODEC_TIME_BASE
/* FIXME: Really bad hack (tm) for NTSC support */
if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
c->time_base.den = 2997;
@@ -482,20 +458,6 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->time_base.den = rd->frs_sec * 100000;
c->time_base.num = ((double) rd->frs_sec_base) * 100000;
}
-#else
- /* FIXME: Really bad hack (tm) for NTSC support */
- if (ffmpeg_type == FFMPEG_DV && rd->frs_sec != 25) {
- c->frame_rate = 2997;
- c->frame_rate_base = 100;
- } else if ((double) ((int) rd->frs_sec_base) ==
- rd->frs_sec_base) {
- c->frame_rate = rd->frs_sec;
- c->frame_rate_base = rd->frs_sec_base;
- } else {
- c->frame_rate = rd->frs_sec * 100000;
- c->frame_rate_base = ((double) rd->frs_sec_base)*100000;
- }
-#endif
c->gop_size = ffmpeg_gop_size;
c->bit_rate = ffmpeg_video_bitrate*1000;
@@ -519,7 +481,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->pix_fmt = PIX_FMT_YUV422P;
}
- if (codec_id == CODEC_ID_XVID) {
+ if (ffmpeg_type == FFMPEG_XVID) {
/* arghhhh ... */
c->pix_fmt = PIX_FMT_YUV420P;
c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X');
@@ -586,9 +548,9 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
st = av_new_stream(of, 1);
if (!st) return NULL;
- c = get_codec_from_stream(st);
+ c = st->codec;
c->codec_id = codec_id;
- c->codec_type = CODEC_TYPE_AUDIO;
+ c->codec_type = AVMEDIA_TYPE_AUDIO;
c->sample_rate = rd->ffcodecdata.audio_mixrate;
c->bit_rate = ffmpeg_audio_bitrate*1000;
@@ -666,13 +628,13 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
BKE_report(reports, RPT_ERROR, "No valid formats found.");
return 0;
}
- fmt = guess_format(NULL, exts[0], NULL);
+ fmt = av_guess_format(NULL, exts[0], NULL);
if (!fmt) {
BKE_report(reports, RPT_ERROR, "No valid formats found.");
return 0;
}
- of = av_alloc_format_context();
+ of = avformat_alloc_context();
if (!of) {
BKE_report(reports, RPT_ERROR, "Error opening output file");
return 0;
@@ -713,7 +675,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
fmt->video_codec = CODEC_ID_H264;
break;
case FFMPEG_XVID:
- fmt->video_codec = CODEC_ID_XVID;
+ fmt->video_codec = CODEC_ID_MPEG4;
break;
case FFMPEG_FLV:
fmt->video_codec = CODEC_ID_FLV1;
@@ -772,7 +734,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
return 0;
}
if (!(fmt->flags & AVFMT_NOFILE)) {
- if (url_fopen(&of->pb, name, URL_WRONLY) < 0) {
+ if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) {
BKE_report(reports, RPT_ERROR, "Could not open file for writing.");
return 0;
}
@@ -780,7 +742,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
av_write_header(of);
outfile = of;
- dump_format(of, 0, name, 1);
+ av_dump_format(of, 0, name, 1);
return 1;
}
@@ -807,7 +769,7 @@ void flush_ffmpeg(void)
int outsize = 0;
int ret = 0;
- AVCodecContext* c = get_codec_from_stream(video_stream);
+ AVCodecContext* c = video_stream->codec;
/* get the delayed frames */
while (1) {
AVPacket packet;
@@ -822,19 +784,15 @@ void flush_ffmpeg(void)
break;
}
if (c->coded_frame->pts != AV_NOPTS_VALUE) {
-#ifdef FFMPEG_CODEC_TIME_BASE
packet.pts = av_rescale_q(c->coded_frame->pts,
c->time_base,
video_stream->time_base);
-#else
- packet.pts = c->coded_frame->pts;
-#endif
fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts);
} else {
fprintf(stderr, "Video Frame PTS: not set\n");
}
if (c->coded_frame->key_frame) {
- packet.flags |= PKT_FLAG_KEY;
+ packet.flags |= AV_PKT_FLAG_KEY;
}
packet.stream_index = video_stream->index;
packet.data = video_buffer;
@@ -845,7 +803,7 @@ void flush_ffmpeg(void)
break;
}
}
- avcodec_flush_buffers(get_codec_from_stream(video_stream));
+ avcodec_flush_buffers(video_stream->codec);
}
/* **********************************************************************
@@ -899,22 +857,23 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo
ffmpeg_autosplit_count = 0;
success = start_ffmpeg_impl(rd, rectx, recty, reports);
-
+#ifdef WITH_AUDASPACE
if(audio_stream)
{
- AVCodecContext* c = get_codec_from_stream(audio_stream);
+ AVCodecContext* c = audio_stream->codec;
AUD_DeviceSpecs specs;
specs.channels = c->channels;
specs.format = AUD_FORMAT_S16;
specs.rate = rd->ffcodecdata.audio_mixrate;
audio_mixdown_device = sound_mixdown(scene, specs, rd->sfra, rd->ffcodecdata.audio_volume);
}
-
+#endif
return success;
}
void end_ffmpeg(void);
+#ifdef WITH_AUDASPACE
static void write_audio_frames(double to_pts)
{
int finished = 0;
@@ -926,6 +885,7 @@ static void write_audio_frames(double to_pts)
}
}
}
+#endif
int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty, ReportList *reports)
{
@@ -945,7 +905,7 @@ int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty,
success= (avframe && write_video_frame(rd, avframe, reports));
if (ffmpeg_autosplit) {
- if (url_ftell(OUTFILE_PB) > FFMPEG_AUTOSPLIT_SIZE) {
+ if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) {
end_ffmpeg();
ffmpeg_autosplit_count++;
success &= start_ffmpeg_impl(rd, rectx, recty, reports);
@@ -953,8 +913,9 @@ int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty,
}
}
+#ifdef WITH_AUDASPACE
write_audio_frames((frame - rd->sfra) / (((double)rd->frs_sec) / rd->frs_sec_base));
-
+#endif
return success;
}
@@ -968,13 +929,15 @@ void end_ffmpeg(void)
write_audio_frames();
}*/
+#ifdef WITH_AUDASPACE
if(audio_mixdown_device)
{
AUD_closeReadDevice(audio_mixdown_device);
audio_mixdown_device = 0;
}
-
- if (video_stream && get_codec_from_stream(video_stream)) {
+#endif
+
+ if (video_stream && video_stream->codec) {
fprintf(stderr, "Flushing delayed frames...\n");
flush_ffmpeg ();
}
@@ -985,8 +948,8 @@ void end_ffmpeg(void)
/* Close the video codec */
- if (video_stream && get_codec_from_stream(video_stream)) {
- avcodec_close(get_codec_from_stream(video_stream));
+ if (video_stream && video_stream->codec) {
+ avcodec_close(video_stream->codec);
printf("zero video stream %p\n", video_stream);
video_stream = 0;
}
@@ -1007,7 +970,7 @@ void end_ffmpeg(void)
}
if (outfile && outfile->oformat) {
if (!(outfile->oformat->flags & AVFMT_NOFILE)) {
- url_fclose(OUTFILE_PB);
+ avio_close(outfile->pb);
}
}
if (outfile) {
@@ -1101,12 +1064,12 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int
switch (o->type) {
case FF_OPT_TYPE_INT:
case FF_OPT_TYPE_INT64:
- val.i = o->default_val;
+ val.i = FFMPEG_DEF_OPT_VAL_INT(o);
idp_type = IDP_INT;
break;
case FF_OPT_TYPE_DOUBLE:
case FF_OPT_TYPE_FLOAT:
- val.f = o->default_val;
+ val.f = FFMPEG_DEF_OPT_VAL_DOUBLE(o);
idp_type = IDP_FLOAT;
break;
case FF_OPT_TYPE_STRING:
@@ -1314,7 +1277,7 @@ void ffmpeg_set_preset(RenderData *rd, int preset)
case FFMPEG_PRESET_XVID:
if(preset == FFMPEG_PRESET_XVID) {
rd->ffcodecdata.type = FFMPEG_AVI;
- rd->ffcodecdata.codec = CODEC_ID_XVID;
+ rd->ffcodecdata.codec = CODEC_ID_MPEG4;
}
else if(preset == FFMPEG_PRESET_THEORA) {
rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken
@@ -1357,7 +1320,7 @@ void ffmpeg_verify_image_type(RenderData *rd)
}
}
else if(rd->imtype == R_XVID) {
- if(rd->ffcodecdata.codec != CODEC_ID_XVID) {
+ if(rd->ffcodecdata.codec != CODEC_ID_MPEG4) {
ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID);
audio= 1;
}
diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c
index 2239f6d3147..d13d15d1269 100644
--- a/source/blender/blenkernel/intern/writeframeserver.c
+++ b/source/blender/blenkernel/intern/writeframeserver.c
@@ -22,6 +22,7 @@
*
*/
+#ifdef WITH_FRAMESERVER
#include <string.h>
#include <stdio.h>
@@ -381,3 +382,4 @@ void end_frameserver(void)
shutdown_socket_system();
}
+#endif /* WITH_FRAMESERVER */