diff options
author | Miika Hamalainen <blender@miikah.org> | 2011-10-22 20:43:23 +0400 |
---|---|---|
committer | Miika Hamalainen <blender@miikah.org> | 2011-10-22 20:43:23 +0400 |
commit | d4541fd891a246f851f647c3259fc26648fc926d (patch) | |
tree | 5397c3a85424b8c08854fa4f9711db4344a790b7 /source/blender/blenkernel/intern | |
parent | 30cba27987362054d16b10e73ddf2601af93be68 (diff) | |
parent | 952560dc028516d60a5318eadbcbd5f2c0668335 (diff) |
Merge with trunk r41197
Diffstat (limited to 'source/blender/blenkernel/intern')
35 files changed, 216 insertions, 300 deletions
diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index 9a3c9462934..8b5cfe1b882 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -44,6 +44,7 @@ #include "DNA_scene_types.h" #include "BLI_edgehash.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_mesh.h" diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 593f50a65e7..bbd439dcb93 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -38,6 +38,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "bmesh_private.h" diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index 62a9601da13..e34f2ee1e50 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -37,7 +37,7 @@ */ - +#include "BLI_listbase.h" #include "MEM_guardedalloc.h" #include "BKE_bmesh.h" #include "bmesh_private.h" diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index bd5241adb6b..c385ad4fcda 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -40,6 +40,7 @@ #include <limits.h> #include "MEM_guardedalloc.h" +#include "BLI_listbase.h" #include "BLI_utildefines.h" #include "BKE_bmesh.h" /** diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 46b9f1425ad..65aa092ba15 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -50,6 +50,7 @@ #include "BLI_memarena.h" #include "BLI_pbvh.h" #include "BLI_utildefines.h" +#include "BLI_linklist.h" #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index cd2c272a1c2..da6dd5bd39d 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1430,6 +1430,16 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECCOPY(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; + + /* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */ + if((part->draw & PART_DRAW_ROTATE_OB) == 0) { + float xvec[3], q[4]; + xvec[0] = -1.f; + xvec[1] = xvec[2] = 0; + vec_to_quat(q, xvec, ob->trackflag, ob->upflag); + quat_to_mat4(obmat, q); + obmat[3][3]= 1.0f; + } /* Normal particles and cached hair live in global space so we need to * remove the real emitter's transformation before 2nd order duplication. @@ -1448,7 +1458,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p copy_m4_m4(mat, tmat); if(part->draw & PART_DRAW_GLOBAL_OB) - VECADD(mat[3], mat[3], vec); + add_v3_v3v3(mat[3], mat[3], vec); dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, oldobmat); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5358a26e660..b2bcd9aa6aa 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -59,7 +59,6 @@ #include "BLI_blenlib.h" #include "BLI_bpath.h" #include "BLI_dynstr.h" -#include "BLI_path_util.h" #include "BLI_utildefines.h" #include "BLI_callbacks.h" @@ -549,7 +548,7 @@ void BKE_write_undo(bContext *C, const char *name) counter= counter % U.undosteps; BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); - BLI_make_file_string("/", filepath, btempdir, numstr); + BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr); /* success= */ /* UNUSED */ BLO_write_file(CTX_data_main(C), filepath, fileflags, NULL, NULL); @@ -719,7 +718,7 @@ void BKE_undo_save_quit(void) /* no undo state to save */ if(undobase.first==undobase.last) return; - BLI_make_file_string("/", str, btempdir, "quit.blend"); + BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); file = open(str,O_BINARY+O_WRONLY+O_CREAT+O_TRUNC, 0666); if(file == -1) { diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 0f8aad00368..72b456fa9ab 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -40,6 +40,7 @@ #include "BLI_editVert.h" #include "BLI_utildefines.h" +#include "BLI_linklist.h" #include "BKE_DerivedMesh.h" diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 1ec573c853a..d30476d44f8 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -40,6 +40,7 @@ #include "BLI_math.h" #include "BLI_edgehash.h" #include "BLI_utildefines.h" +#include "BLI_linklist.h" #include "BKE_cdderivedmesh.h" #include "BKE_cloth.h" @@ -974,7 +975,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) * SPRING NETWORK BUILDING IMPLEMENTATION BEGIN ***************************************************************************************/ -// be carefull: implicit solver has to be resettet when using this one! +// be careful: implicit solver has to be resettet when using this one! // --> only for implicit handling of this spring! int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned int indexB, float restlength, int spring_type) { diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 591e0b6a8d2..8eff86d846e 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -41,7 +41,6 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_utildefines.h" @@ -1067,7 +1066,7 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta cob->matrix[2][2]=size[2]; /* targetmat[2] instead of ownermat[2] is passed to vectomat - * for backwards compatability it seems... (Aligorith) + * for backwards compatibility it seems... (Aligorith) */ sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vectomat(vec, ct->matrix[2], @@ -2104,7 +2103,7 @@ static void actcon_new_data (void *cdata) { bActionConstraint *data= (bActionConstraint *)cdata; - /* set type to 20 (Loc X), as 0 is Rot X for backwards compatability */ + /* set type to 20 (Loc X), as 0 is Rot X for backwards compatibility */ data->type = 20; } @@ -2161,7 +2160,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint 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: + /* data->type is mapped as follows for backwards compatibility: * 00,01,02 - rotation (it used to be like this) * 10,11,12 - scaling * 20,21,22 - location @@ -4351,7 +4350,7 @@ short proxylocked_constraints_owner (Object *ob, bPoseChannel *pchan) * constraints either had one or no targets. It used to be called during the main constraint solving * loop, but is now only used for the remaining cases for a few constraints. * - * None of the actual calculations of the matricies should be done here! Also, this function is + * None of the actual calculations of the matrices should be done here! Also, this function is * not to be used by any new constraints, particularly any that have multiple targets. */ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 81f57ea12ee..6bd0be3f861 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -47,7 +47,6 @@ #include "DNA_ID.h" #include "BLI_blenlib.h" -#include "BLI_path_util.h" #include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_mempool.h" diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 80a40c0a3a3..d3c5942b685 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -38,6 +38,7 @@ #include "BLI_winstuff.h" #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" @@ -1962,7 +1963,7 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay) if(node->id==(ID *)sce) { SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); if(srl && (srl->lay & lay_changed)) - NodeTagChanged(sce->nodetree, node); + nodeUpdate(sce->nodetree, node); } } } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 5ce7b82a45f..e3e769253f1 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -33,7 +33,6 @@ #include <stddef.h> -#include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include <math.h> #include <stdlib.h> @@ -59,8 +58,6 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_jitter.h" -#include "BLI_listbase.h" -#include "BLI_noise.h" #include "BLI_rand.h" #include "BLI_utildefines.h" diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index e2326b005c1..0303f580e67 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -705,7 +705,7 @@ void bezt_add_to_cfra_elem (ListBase *lb, BezTriple *bezt) /* ***************************** Samples Utilities ******************************* */ /* Some utilities for working with FPoints (i.e. 'sampled' animation curve data, such as - * data imported from BVH/Mocap files), which are specialised for use with high density datasets, + * data imported from BVH/Mocap files), which are specialized for use with high density datasets, * which BezTriples/Keyframe data are ill equipped to do. */ diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 1c2f1c8487c..9247646b927 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -33,7 +33,6 @@ #include <stddef.h> -#include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 9c01b35b91a..068e70bbb50 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -64,142 +64,6 @@ static ListBase ttfdata= {NULL, NULL}; -/* UTF-8 <-> wchar transformations */ -size_t chtoutf8(const unsigned long c, char o[4]) -{ - // Variables and initialization -/* memset(o, 0, 4); */ - - // Create the utf-8 string - if (c < 0x80) { - o[0] = (char) c; - return 1; - } - else if (c < 0x800) { - o[0] = (0xC0 | (c>>6)); - o[1] = (0x80 | (c & 0x3f)); - return 2; - } - else if (c < 0x10000) { - o[0] = (0xe0 | (c >> 12)); - o[1] = (0x80 | (c >>6 & 0x3f)); - o[2] = (0x80 | (c & 0x3f)); - return 3; - } - else if (c < 0x200000) { - o[0] = (0xf0 | (c>>18)); - o[1] = (0x80 | (c >>12 & 0x3f)); - o[2] = (0x80 | (c >> 6 & 0x3f)); - o[3] = (0x80 | (c & 0x3f)); - return 4; - } - - /* should we assert here? */ - return 0; -} - -void wcs2utf8s(char *dst, const wchar_t *src) -{ - while(*src) { - dst += chtoutf8(*src++, dst); - } - - *dst= '\0'; -} - -size_t wcsleninu8(wchar_t *src) -{ - char ch_dummy[4]; - size_t len = 0; - - while(*src) { - len += chtoutf8(*src++, ch_dummy); - } - - return len; -} - -static size_t utf8slen(const char *strc) -{ - int len=0; - - while(*strc) { - if ((*strc & 0xe0) == 0xc0) { - if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00) - strc++; - } else if ((*strc & 0xf0) == 0xe0) { - if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00) - strc += 2; - } else if ((*strc & 0xf8) == 0xf0) { - if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00) - strc += 3; - } - - strc++; - len++; - } - - return len; -} - - -/* Converts Unicode to wchar - -According to RFC 3629 "UTF-8, a transformation format of ISO 10646" -(http://tools.ietf.org/html/rfc3629), the valid UTF-8 encoding are: - - Char. number range | UTF-8 octet sequence - (hexadecimal) | (binary) - --------------------+--------------------------------------------- - 0000 0000-0000 007F | 0xxxxxxx - 0000 0080-0000 07FF | 110xxxxx 10xxxxxx - 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - -If the encoding incidated by the first character is incorrect (because the -1 to 3 following characters do not match 10xxxxxx), the output is a '?' and -only a single input character is consumed. - -*/ - -size_t utf8towchar(wchar_t *w, const char *c) -{ - int len=0; - - if(w==NULL || c==NULL) return(0); - - while(*c) { - if ((*c & 0xe0) == 0xc0) { - if((c[1] & 0x80) && (c[1] & 0x40) == 0x00) { - *w=((c[0] &0x1f)<<6) | (c[1]&0x3f); - c++; - } else { - *w = '?'; - } - } else if ((*c & 0xf0) == 0xe0) { - if((c[1] & c[2] & 0x80) && ((c[1] | c[2]) & 0x40) == 0x00) { - *w=((c[0] & 0x0f)<<12) | ((c[1]&0x3f)<<6) | (c[2]&0x3f); - c += 2; - } else { - *w = '?'; - } - } else if ((*c & 0xf8) == 0xf0) { - if((c[1] & c[2] & c[3] & 0x80) && ((c[1] | c[2] | c[3]) & 0x40) == 0x00) { - *w=((c[0] & 0x07)<<18) | ((c[1]&0x1f)<<12) | ((c[2]&0x3f)<<6) | (c[3]&0x3f); - c += 3; - } else { - *w = '?'; - } - } else - *w=(c[0] & 0x7f); - - c++; - w++; - len++; - } - return len; -} - /* The vfont code */ void free_vfont(struct VFont *vf) { @@ -691,10 +555,10 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if(vfont == NULL) return NULL; // Create unicode string - utf8len = utf8slen(cu->str); + utf8len = BLI_strlen_utf8(cu->str); mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); - utf8towchar(mem, cu->str); + BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1); // Count the wchar_t string length slen = wcslen(mem); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index cf8f96c143a..37982e7fec9 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -906,8 +906,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_MARKER) { char *name = scene_find_last_marker_name(scene, CFRA); - - if (name) strcpy(text, name); + + if (name) BLI_strncpy(text, name, sizeof(text)); else strcpy(text, "<none>"); BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text); @@ -980,7 +980,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_SEQSTRIP) { Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra); - if (seq) strcpy(text, seq->name+2); + if (seq) BLI_strncpy(text, seq->name+2, sizeof(text)); else strcpy(text, "<none>"); BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text); @@ -1514,7 +1514,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) Scene *scene; for(scene= G.main->scene.first; scene; scene= scene->id.next) { if(scene->nodetree) { - NodeTagIDChanged(scene->nodetree, &ima->id); + nodeUpdateID(scene->nodetree, &ima->id); } } } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 91f3c7a22ba..609f6cd38f1 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1034,12 +1034,14 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) /* first bone target */ dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; + dtar->idtype= ID_OB; if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); /* second bone target (name was stored in same var as the first one) */ dtar= &dvar->targets[1]; dtar->id= (ID *)idriver->ob; + dtar->idtype= ID_OB; if (idriver->name[0]) // xxx... for safety BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); } @@ -1051,6 +1053,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) /* only requires a single target */ dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; + dtar->idtype= ID_OB; if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); @@ -1065,6 +1068,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) /* only requires single target */ dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; + dtar->idtype= ID_OB; dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); } } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 9e48e691b87..3baf8e04b90 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1280,9 +1280,9 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(a, a+1, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); + do_key(a, a+1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(a, a+1, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); + cp_key(a, a+1, tot, out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } else { @@ -1292,7 +1292,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int for(kb= key->block.first; kb; kb= kb->next) kb->weights= get_weights_array(ob, kb->vgroup); - do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); + do_rel_key(0, tot, tot, out, key, actkb, KEY_MODE_DUMMY); for(kb= key->block.first; kb; kb= kb->next) { if(kb->weights) MEM_freeN(kb->weights); @@ -1386,7 +1386,7 @@ float *do_ob_key(Scene *scene, Object *ob) if(ELEM(ob->type, OB_MESH, OB_LATTICE)) { float *weights= get_weights_array(ob, kb->vgroup); - cp_key(0, tot, tot, (char*)out, key, actkb, kb, weights, 0); + cp_key(0, tot, tot, out, key, actkb, kb, weights, 0); if(weights) MEM_freeN(weights); } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 9de75a49998..2056762e627 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -52,6 +52,10 @@ #include "DNA_meshdata_types.h" #include "BLI_utildefines.h" +#include "BLI_path_util.h" +#include "BLI_listbase.h" +#include "BLI_linklist.h" +#include "BLI_string.h" #include "BKE_bmesh.h" #include "BKE_cloth.h" @@ -86,8 +90,8 @@ ModifierData *modifier_new(int type) ModifierTypeInfo *mti = modifierType_getInfo(type); ModifierData *md = MEM_callocN(mti->structSize, mti->structName); - // FIXME: we need to make the name always be unique somehow... - strcpy(md->name, mti->name); + /* note, this name must be made unique later */ + BLI_strncpy(md->name, mti->name, sizeof(md->name)); md->type = type; md->mode = eModifierMode_Realtime diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 97347d85deb..15513675c7a 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -42,6 +42,9 @@ #include "MEM_guardedalloc.h" #include "BLI_utildefines.h" +#include "BLI_path_util.h" +#include "BLI_listbase.h" +#include "BLI_string.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f0be3c99f13..cb1f52a6265 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -184,7 +184,7 @@ bNodeSocket *nodeAddSocket(bNodeTree *ntree, bNode *node, int in_out, const char else if (in_out==SOCK_OUT) BLI_addtail(&node->outputs, sock); - ntree->update |= NTREE_UPDATE_NODES; + node->update |= NODE_UPDATE; return sock; } @@ -197,7 +197,7 @@ bNodeSocket *nodeInsertSocket(bNodeTree *ntree, bNode *node, int in_out, bNodeSo else if (in_out==SOCK_OUT) BLI_insertlinkbefore(&node->outputs, next_sock, sock); - ntree->update |= NTREE_UPDATE_NODES; + node->update |= NODE_UPDATE; return sock; } @@ -221,7 +221,7 @@ void nodeRemoveSocket(bNodeTree *ntree, bNode *node, bNodeSocket *sock) MEM_freeN(sock->default_value); MEM_freeN(sock); - ntree->update |= NTREE_UPDATE_NODES; + node->update |= NODE_UPDATE; } void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node) @@ -246,7 +246,7 @@ void nodeRemoveAllSockets(bNodeTree *ntree, bNode *node) BLI_freelistN(&node->outputs); - ntree->update |= NTREE_UPDATE_NODES; + node->update |= NODE_UPDATE; } /* finds a node based on its name */ @@ -374,7 +374,7 @@ void nodeMakeDynamicType(bNode *node) /*node->typeinfo= MEM_dupallocN(ntype);*/ bNodeType *newtype= MEM_callocN(sizeof(bNodeType), "dynamic bNodeType"); *newtype= *ntype; - strcpy(newtype->name, ntype->name); + BLI_strncpy(newtype->name, ntype->name, sizeof(newtype->name)); node->typeinfo= newtype; } } @@ -823,7 +823,7 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node) if(link->fromnode==node) { lb= &node->outputs; if (link->tonode) - NodeTagChanged(ntree, link->tonode); + link->tonode->update |= NODE_UPDATE; } else if(link->tonode==node) lb= &node->inputs; @@ -1495,18 +1495,19 @@ void ntreeUpdateTree(bNodeTree *ntree) /* update individual nodes */ for (n=0; n < totnodes; ++n) { node = deplist[n]; - if (ntreetype->update_node) - ntreetype->update_node(ntree, node); - else if (node->typeinfo->updatefunc) - node->typeinfo->updatefunc(ntree, node); + + /* node tree update tags override individual node update flags */ + if ((node->update & NODE_UPDATE) || (ntree->update & NTREE_UPDATE)) { + if (ntreetype->update_node) + ntreetype->update_node(ntree, node); + else if (node->typeinfo->updatefunc) + node->typeinfo->updatefunc(ntree, node); + } + /* clear update flag */ + node->update = 0; } MEM_freeN(deplist); - - /* ensures only a single output node is enabled, texnode allows multiple though */ - if(ntree->type!=NTREE_TEXTURE) - ntreeSetOutput(ntree); - } /* general tree updates */ @@ -1518,6 +1519,9 @@ void ntreeUpdateTree(bNodeTree *ntree) if (ntreetype->update) ntreetype->update(ntree); else { + /* Trees can be associated with a specific node type (i.e. group nodes), + * in that case a tree update function may be defined by that node type. + */ bNodeType *ntype= node_get_type(ntree, ntree->nodetype); if (ntype && ntype->updatetreefunc) ntype->updatetreefunc(ntree); @@ -1530,24 +1534,24 @@ void ntreeUpdateTree(bNodeTree *ntree) ntree->update = 0; } -void NodeTagChanged(bNodeTree *ntree, bNode *node) +void nodeUpdate(bNodeTree *ntree, bNode *node) { - bNodeTreeType *ntreetype = ntreeGetType(ntree->type); + bNodeTreeType *ntreetype= ntreeGetType(ntree->type); - /* extra null pointer checks here because this is called when unlinking - unknown nodes on file load, so typeinfo pointers may not be set */ - if (ntreetype && ntreetype->update_node) + if (ntreetype->update_node) ntreetype->update_node(ntree, node); - else if (node->typeinfo && node->typeinfo->updatefunc) + else if (node->typeinfo->updatefunc) node->typeinfo->updatefunc(ntree, node); + /* clear update flag */ + node->update = 0; } -int NodeTagIDChanged(bNodeTree *ntree, ID *id) +int nodeUpdateID(bNodeTree *ntree, ID *id) { bNodeTreeType *ntreetype; bNode *node; int change = FALSE; - + if(ELEM(NULL, id, ntree)) return change; @@ -1558,6 +1562,8 @@ int NodeTagIDChanged(bNodeTree *ntree, ID *id) if(node->id==id) { change = TRUE; ntreetype->update_node(ntree, node); + /* clear update flag */ + node->update = 0; } } } @@ -1567,6 +1573,8 @@ int NodeTagIDChanged(bNodeTree *ntree, ID *id) change = TRUE; if (node->typeinfo->updatefunc) node->typeinfo->updatefunc(ntree, node); + /* clear update flag */ + node->update = 0; } } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 2c8975e9cb4..70b0b7727c4 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -182,7 +182,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char // convert relative filenames to absolute filenames - strcpy(name, filename); + BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, basepath); // open the file @@ -192,7 +192,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char if (file <= 0) { BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); } else { - filelen = BLI_filesize(file); + filelen = BLI_file_descriptor_size(file); if (filelen == 0) { // MEM_mallocN complains about MEM_mallocN(0, "bla"); @@ -240,7 +240,7 @@ void packAll(Main *bmain, ReportList *reports) } -/* +#if 0 // attempt to create a function that generates an unique filename // this will work when all funtions in fileops.c understand relative filenames... @@ -249,6 +249,7 @@ static char *find_new_name(char *name) { char tempname[FILE_MAXDIR + FILE_MAXFILE]; char *newname; + size_t len; if (fop_exists(name)) { for (number = 1; number <= 999; number++) { @@ -258,14 +259,12 @@ static char *find_new_name(char *name) } } } - - newname = mallocN(strlen(tempname) + 1, "find_new_name"); - strcpy(newname, tempname); - - return(newname); + len= strlen(tempname) + 1; + newname = MEM_mallocN(len, "find_new_name"); + memcpy(newname, tempname, len * sizeof(char)); + return newname; } - -*/ +#endif int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, int guimode) { @@ -277,14 +276,14 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i if (guimode) {} //XXX waitcursor(1); - strcpy(name, filename); + BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, G.main->name); if (BLI_exists(name)) { for (number = 1; number <= 999; number++) { - sprintf(tempname, "%s.%03d_", name, number); + BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number); if (! BLI_exists(tempname)) { - if (BLI_copy_fileops(name, tempname) == RET_OK) { + if (BLI_copy(name, tempname) == RET_OK) { remove_tmp = TRUE; } break; @@ -342,7 +341,7 @@ int checkPackedFile(const char *filename, PackedFile *pf) char buf[4096]; char name[FILE_MAXDIR + FILE_MAXFILE]; - strcpy(name, filename); + BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, G.main->name); if (stat(name, &st)) { @@ -392,9 +391,10 @@ there was an error or when the user desides to cancel the operation. */ -char *unpackFile(ReportList *reports, char *abs_name, char *local_name, PackedFile *pf, int how) +char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how) { - char *newname = NULL, *temp = NULL; + char *newname = NULL; + const char *temp = NULL; // char newabs[FILE_MAXDIR + FILE_MAXFILE]; // char newlocal[FILE_MAXDIR + FILE_MAXFILE]; @@ -437,12 +437,11 @@ char *unpackFile(ReportList *reports, char *abs_name, char *local_name, PackedFi } if (temp) { - newname = MEM_mallocN(strlen(temp) + 1, "unpack_file newname"); - strcpy(newname, temp); + newname= BLI_strdup(temp); } } - return (newname); + return newname; } @@ -453,17 +452,17 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) int ret_value = RET_ERROR; if (vfont != NULL) { - strcpy(localname, vfont->name); + BLI_strncpy(localname, vfont->name, sizeof(localname)); BLI_splitdirstring(localname, fi); - sprintf(localname, "//fonts/%s", fi); + BLI_snprintf(localname, sizeof(localname), "//fonts/%s", fi); newname = unpackFile(reports, vfont->name, localname, vfont->packedfile, how); if (newname != NULL) { ret_value = RET_OK; freePackedFile(vfont->packedfile); vfont->packedfile = NULL; - strcpy(vfont->name, newname); + BLI_strncpy(vfont->name, newname, sizeof(vfont->name)); MEM_freeN(newname); } } @@ -478,13 +477,13 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) int ret_value = RET_ERROR; if (sound != NULL) { - strcpy(localname, sound->name); + BLI_strncpy(localname, sound->name, sizeof(localname)); BLI_splitdirstring(localname, fi); - sprintf(localname, "//sounds/%s", fi); + BLI_snprintf(localname, sizeof(localname), "//sounds/%s", fi); newname = unpackFile(reports, sound->name, localname, sound->packedfile, how); if (newname != NULL) { - strcpy(sound->name, newname); + BLI_strncpy(sound->name, newname, sizeof(sound->name)); MEM_freeN(newname); freePackedFile(sound->packedfile); @@ -506,16 +505,16 @@ int unpackImage(ReportList *reports, Image *ima, int how) int ret_value = RET_ERROR; if (ima != NULL) { - strcpy(localname, ima->name); + BLI_strncpy(localname, ima->name, sizeof(localname)); BLI_splitdirstring(localname, fi); - sprintf(localname, "//textures/%s", fi); - + BLI_snprintf(localname, sizeof(localname), "//textures/%s", fi); + newname = unpackFile(reports, ima->name, localname, ima->packedfile, how); if (newname != NULL) { ret_value = RET_OK; freePackedFile(ima->packedfile); ima->packedfile = NULL; - strcpy(ima->name, newname); + BLI_strncpy(ima->name, newname, sizeof(ima->name)); MEM_freeN(newname); BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 61dd36fc34d..fdaeb8fb2d3 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -55,6 +55,7 @@ #include "BLI_kdtree.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_linklist.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -4393,33 +4394,50 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *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); - normalize_v3(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; + + if(psys->part->rotmode == PART_ROT_VEL) { + copy_m3_m4(nmat, ob->imat); + transpose_m3(nmat); + mul_m3_v3(nmat, nor); + normalize_v3(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; + } } - else { - nor[0] = 1.0f; - nor[1] = 0.0f; - nor[2] = 0.0f; + cross_v3_v3v3(side, nor, vec); + normalize_v3(side); + + /* rotate side vector around vec */ + if(psys->part->phasefac != 0) { + float q_phase[4]; + float phasefac = psys->part->phasefac; + if(psys->part->randphasefac != 0.0f) + phasefac += psys->part->randphasefac * PSYS_FRAND((pa-psys->particles) + 20); + axis_angle_to_quat( q_phase, vec, phasefac*(float)M_PI); + + mul_qt_v3(q_phase, side); } - } - 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); + cross_v3_v3v3(nor, vec, side); + + unit_m4(mat); + VECCOPY(mat[0], vec); + VECCOPY(mat[1], side); + VECCOPY(mat[2], nor); + } + else { + quat_to_mat4(mat, pa->state.rot); + } *scale= len; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 6b601ed4b1a..cebefe81495 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -36,7 +36,6 @@ #include <stddef.h> -#include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include <stdlib.h> #include <math.h> @@ -67,11 +66,9 @@ #include "BLI_blenlib.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" -#include "BLI_listbase.h" #include "BLI_threads.h" -#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */ -#include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLI_linklist.h" #include "BKE_main.h" #include "BKE_animsys.h" @@ -1607,8 +1604,8 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P } - /* -velocity */ - if(part->randfac != 0.0f){ + /* -velocity (boids need this even if there's no random velocity) */ + if(part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)){ r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f); r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f); r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index ab122bb1d0c..4b84654d113 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1039,7 +1039,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) else if (G.relbase_valid || lib) { char file[MAX_PTCACHE_PATH]; /* we dont want the dir, only the file */ - BLI_split_dirfile(blendfilename, NULL, file); + BLI_split_file_part(blendfilename, file, sizeof(file)); i = strlen(file); /* remove .blend */ @@ -1052,8 +1052,8 @@ static int ptcache_path(PTCacheID *pid, char *filename) } /* use the temp path. this is weak but better then not using point cache at all */ - /* btempdir is assumed to exist and ALWAYS has a trailing slash */ - BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid())); + /* temporary directory is assumed to exist and ALWAYS has a trailing slash */ + BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", BLI_temporary_dir(), abs(getpid())); return BLI_add_slash(filename); /* new strlen() */ } @@ -2516,7 +2516,7 @@ void BKE_ptcache_remove(void) ptcache_path(NULL, path); - if (BLI_exist(path)) { + if (BLI_exists(path)) { /* The pointcache dir exists? - remove all pointcache */ DIR *dir; @@ -3044,24 +3044,24 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) char ext[MAX_PTCACHE_PATH]; /* save old name */ - strcpy(old_name, pid->cache->name); + BLI_strncpy(old_name, pid->cache->name, sizeof(old_name)); /* get "from" filename */ - strcpy(pid->cache->name, from); + BLI_strncpy(pid->cache->name, from, sizeof(pid->cache->name)); len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */ ptcache_path(pid, path); dir = opendir(path); if(dir==NULL) { - strcpy(pid->cache->name, old_name); + BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name)); return; } BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); /* put new name into cache */ - strcpy(pid->cache->name, to); + BLI_strncpy(pid->cache->name, to, sizeof(pid->cache->name)); while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ @@ -3116,7 +3116,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) if(cache->index >= 0) BLI_snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, cache->index); else - strcpy(ext, PTCACHE_EXT); + BLI_strncpy(ext, PTCACHE_EXT, sizeof(ext)); while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index cdf2e39a4dd..e0e2876f79e 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -166,7 +166,7 @@ void unique_property(bProperty *first, bProperty *prop, int force) int i= 0; /* strip numbers */ - strcpy(base_name, prop->name); + BLI_strncpy(base_name, prop->name, sizeof(base_name)); for(i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) { base_name[i]= '\0'; } @@ -178,7 +178,7 @@ void unique_property(bProperty *first, bProperty *prop, int force) strcat(new_name, num); } while(get_property__internal(first, prop, new_name)); - strcpy(prop->name, new_name); + BLI_strncpy(prop->name, new_name, sizeof(prop->name)); } } } @@ -257,7 +257,7 @@ void set_property(bProperty *prop, char *str) *((float *)&prop->data)= (float)atof(str); break; case GPROP_STRING: - strcpy(prop->poin, str); + strcpy(prop->poin, str); /* TODO - check size? */ break; } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index d8d6ed6ea6d..943066537d5 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -827,7 +827,7 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y, } } -/* carefull: also used by speed effect! */ +/* careful: also used by speed effect! */ static struct ImBuf* do_cross_effect( SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5a2c53f5b9b..cf03a8d3f36 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -61,9 +61,10 @@ #include "BKE_sequencer.h" #include "BKE_fcurve.h" #include "BKE_scene.h" -#include "RNA_access.h" #include "BKE_utildefines.h" +#include "RNA_access.h" + #include "RE_pipeline.h" #include <pthread.h> @@ -866,8 +867,8 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq) SeqUniqueInfo sui; char *dot; sui.seq= seq; - strcpy(sui.name_src, seq->name+2); - strcpy(sui.name_dest, seq->name+2); + BLI_strncpy(sui.name_src, seq->name+2, sizeof(sui.name_src)); + BLI_strncpy(sui.name_dest, seq->name+2, sizeof(sui.name_dest)); sui.count= 1; sui.match= 1; /* assume the worst to start the loop */ @@ -887,7 +888,7 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq) seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_cb, &sui); } - strcpy(seq->name+2, sui.name_dest); + BLI_strncpy(seq->name+2, sui.name_dest, sizeof(seq->name)-2); } static const char *give_seqname_by_type(int type) @@ -1204,7 +1205,7 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, sorry folks, please rebuild your proxies... */ if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) { - strcpy(dir, seq->strip->proxy->dir); + BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); } else if (seq->type == SEQ_IMAGE) { BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir); } else { @@ -3360,9 +3361,9 @@ int seq_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) SWAP(Sequence, *seq_a, *seq_b); /* swap back names so animation fcurves dont get swapped */ - strcpy(name, seq_a->name+2); - strcpy(seq_a->name+2, seq_b->name+2); - strcpy(seq_b->name+2, name); + BLI_strncpy(name, seq_a->name+2, sizeof(name)); + BLI_strncpy(seq_a->name+2, seq_b->name+2, sizeof(seq_b->name)-2); + BLI_strncpy(seq_b->name+2, name, sizeof(seq_b->name)-2); /* swap back opacity, and overlay mode */ SWAP(int, seq_a->blend_mode, seq_b->blend_mode); @@ -3647,7 +3648,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo /* 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); + BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0); @@ -3706,7 +3707,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo /* 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); + BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); calc_sequence_disp(scene, seq); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 85140841f15..c1833b39b8b 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -131,15 +131,15 @@ struct Scene; struct DerivedMesh; struct SmokeModifierData; -// forward declerations -static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct); -void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len); -static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs); - #define TRI_UVOFFSET (1./4.) +#ifdef WITH_SMOKE +/* forward declerations */ +static void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int numfaces, int numtris, int **tridivs, float cell_len); +static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int correct); +static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs); +#else /* WITH_SMOKE */ /* 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)) {} @@ -148,9 +148,9 @@ void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(s 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 - +#endif /* WITH_SMOKE */ +#ifdef 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) @@ -455,7 +455,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) } /*! init triangle divisions */ -void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFace *faces, int numfaces, int numtris, int **tridivs, float cell_len) +static void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFace *faces, int numfaces, int numtris, int **tridivs, float cell_len) { // mTriangleDivs1.resize( faces.size() ); // mTriangleDivs2.resize( faces.size() ); @@ -554,6 +554,8 @@ void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFace *fac } } +#endif /* WITH_SMOKE */ + static void smokeModifier_freeDomain(SmokeModifierData *smd) { if(smd->domain) @@ -812,13 +814,12 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData } } +#ifdef WITH_SMOKE // 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; @@ -1660,4 +1661,4 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa } } -#endif // WITH_SMOKE +#endif /* WITH_SMOKE */ diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 88f72c33802..cd147f4dbed 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -68,6 +68,7 @@ variables on the UI for now #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_listbase.h" #include "BLI_ghash.h" #include "BLI_threads.h" @@ -207,7 +208,7 @@ static float sb_time_scale(Object *ob) } return (1.0f); /* - this would be frames/sec independant timing assuming 25 fps is default + this would be frames/sec independent timing assuming 25 fps is default but does not work very well with NLA return (25.0f/scene->r.frs_sec) */ @@ -2818,7 +2819,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa if (ob->softflag & OB_SB_FACECOLL) scan_for_ext_face_forces(ob,timenow); /* finish matrix and solve */ -#if (0) // remove onl linking for now .. still i am not sure .. the jacobian can be usefull .. so keep that BM +#if (0) // remove onl linking for now .. still i am not sure .. the jacobian can be useful .. so keep that BM if(nl_flags & NLF_SOLVE){ //double sct,sst=PIL_check_seconds_timer(); for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { @@ -3540,7 +3541,7 @@ static void lattice_to_softbody(Scene *scene, Object *ob) } } - /* create some helper edges to enable SB lattice to be usefull at all */ + /* create some helper edges to enable SB lattice to be useful at all */ if (ob->softflag & OB_SB_EDGES){ makelatticesprings(lt,ob->soft->bspring,ob->softflag & OB_SB_QUADS,ob); build_bps_springlist(ob); /* link bps to springs */ diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index f2d92154c66..02e381fe9b4 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -63,6 +63,10 @@ #include "BKE_sequencer.h" #include "BKE_scene.h" +// evil quiet NaN definition +static const int NAN_INT = 0x7FC00000; +#define NAN_FLT *((float*)(&NAN_INT)) + #ifdef WITH_AUDASPACE // evil global ;-) static int sound_cfra; @@ -75,9 +79,9 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) char str[FILE_MAX]; char *path; - int len; + size_t len; - strcpy(str, filename); + BLI_strncpy(str, filename, sizeof(str)); path = /*bmain ? bmain->name :*/ G.main->name; @@ -295,7 +299,10 @@ void sound_cache(struct bSound* sound) AUD_unload(sound->cache); sound->cache = AUD_bufferSound(sound->handle); - sound->playback_handle = sound->cache; + if(sound->cache) + sound->playback_handle = sound->cache; + else + sound->playback_handle = sound->handle; } void sound_cache_notifying(struct Main* main, struct bSound* sound) @@ -332,6 +339,8 @@ void sound_load(struct Main *bmain, struct bSound* sound) sound->playback_handle = NULL; } + sound_free_waveform(sound); + // XXX unused currently #if 0 switch(sound->type) @@ -625,7 +634,7 @@ float sound_sync_scene(struct Scene *scene) else return AUD_getPosition(scene->sound_scene_handle); } - return 0.0f; + return NAN_FLT; } int sound_scene_playing(struct Scene *scene) @@ -782,7 +791,7 @@ 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 Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {} -float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; } +float sound_sync_scene(struct Scene *UNUSED(scene)) { return NAN_FLT; } 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; } void sound_read_waveform(struct bSound* sound) { (void)sound; } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index d487875dd55..e39cfafe7b7 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -141,7 +141,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAgin ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8); } - ccgSubSurf_setCalcVertexNormals(ccgSS, 1, BLI_STRUCT_OFFSET(DMGridData, no)); + ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no)); return ccgSS; } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index d344f79bb6c..7d720aed62c 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -992,7 +992,7 @@ void autotexname(Tex *tex) if(tex->type==TEX_IMAGE) { ima= tex->ima; if(ima) { - strcpy(di, ima->name); + BLI_strncpy(di, ima->name, sizeof(di)); BLI_splitdirstring(di, fi); strcpy(di, "I."); strcat(di, fi); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 58a2f45e876..7b414f7746a 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -407,8 +407,7 @@ static void set_ffmpeg_properties(RenderData *rd, AVCodecContext *c, const char return; } - prop = IDP_GetPropertyFromGroup( - rd->ffcodecdata.properties, (char*) prop_name); + prop = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, prop_name); if (!prop) { return; } @@ -1025,8 +1024,7 @@ void ffmpeg_property_del(RenderData *rd, void *type, void *prop_) return; } - group = IDP_GetPropertyFromGroup( - rd->ffcodecdata.properties, (char*) type); + group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type); if (group && prop) { IDP_RemFromGroup(group, prop); IDP_FreeProperty(prop); @@ -1057,11 +1055,10 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int = IDP_New(IDP_GROUP, val, "ffmpeg"); } - group = IDP_GetPropertyFromGroup( - rd->ffcodecdata.properties, (char*) type); + group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type); if (!group) { - group = IDP_New(IDP_GROUP, val, (char*) type); + group = IDP_New(IDP_GROUP, val, type); IDP_AddToGroup(rd->ffcodecdata.properties, group); } |