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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-02-14 02:47:30 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-02-14 02:47:30 +0300
commit3789c398ff2b2fd7f0eadba45686b0e235186f4a (patch)
treeafe1f241f03d17de7df10a414516f03c277518a1 /source/blender/blenkernel/intern
parent5ed1597e2672cc0e59f8a1ca7c54ae3ad9206b8c (diff)
parent4ca2905ead92f23b1aca7bdbcc23c605dd830a87 (diff)
Merged changes in the trunk up to revision 34828.
Conflicts resolved: source/blender/makesrna/RNA_enum_types.h
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c4
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c135
-rw-r--r--source/blender/blenkernel/intern/action.c12
-rw-r--r--source/blender/blenkernel/intern/anim.c28
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c6
-rw-r--r--source/blender/blenkernel/intern/armature.c29
-rw-r--r--source/blender/blenkernel/intern/blender.c18
-rw-r--r--source/blender/blenkernel/intern/bmfont.c1
-rw-r--r--source/blender/blenkernel/intern/boids.c2
-rw-r--r--source/blender/blenkernel/intern/brush.c18
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c23
-rw-r--r--source/blender/blenkernel/intern/collision.c8
-rw-r--r--source/blender/blenkernel/intern/constraint.c136
-rw-r--r--source/blender/blenkernel/intern/context.c4
-rw-r--r--source/blender/blenkernel/intern/curve.c53
-rw-r--r--source/blender/blenkernel/intern/customdata.c18
-rw-r--r--source/blender/blenkernel/intern/deform.c27
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c64
-rw-r--r--source/blender/blenkernel/intern/displist.c20
-rw-r--r--source/blender/blenkernel/intern/effect.c37
-rw-r--r--source/blender/blenkernel/intern/exotic.c19
-rw-r--r--source/blender/blenkernel/intern/fcurve.c4
-rw-r--r--source/blender/blenkernel/intern/font.c39
-rw-r--r--source/blender/blenkernel/intern/icons.c22
-rw-r--r--source/blender/blenkernel/intern/idcode.c2
-rw-r--r--source/blender/blenkernel/intern/idprop.c16
-rw-r--r--source/blender/blenkernel/intern/image.c80
-rw-r--r--source/blender/blenkernel/intern/image_gen.c2
-rw-r--r--source/blender/blenkernel/intern/ipo.c48
-rw-r--r--source/blender/blenkernel/intern/key.c24
-rw-r--r--source/blender/blenkernel/intern/lattice.c12
-rw-r--r--source/blender/blenkernel/intern/library.c26
-rw-r--r--source/blender/blenkernel/intern/material.c42
-rw-r--r--source/blender/blenkernel/intern/mball.c52
-rw-r--r--source/blender/blenkernel/intern/mesh.c90
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c379
-rw-r--r--source/blender/blenkernel/intern/modifier.c7
-rw-r--r--source/blender/blenkernel/intern/multires.c20
-rw-r--r--source/blender/blenkernel/intern/nla.c4
-rw-r--r--source/blender/blenkernel/intern/node.c455
-rw-r--r--source/blender/blenkernel/intern/object.c40
-rw-r--r--source/blender/blenkernel/intern/packedFile.c4
-rw-r--r--source/blender/blenkernel/intern/particle.c286
-rw-r--r--source/blender/blenkernel/intern/particle_system.c449
-rw-r--r--source/blender/blenkernel/intern/pointcache.c15
-rw-r--r--source/blender/blenkernel/intern/property.c4
-rw-r--r--source/blender/blenkernel/intern/sca.c14
-rw-r--r--source/blender/blenkernel/intern/scene.c65
-rw-r--r--source/blender/blenkernel/intern/screen.c2
-rw-r--r--source/blender/blenkernel/intern/seqcache.c28
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c60
-rw-r--r--source/blender/blenkernel/intern/sequencer.c73
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.c11
-rw-r--r--source/blender/blenkernel/intern/sketch.c4
-rw-r--r--source/blender/blenkernel/intern/softbody.c20
-rw-r--r--source/blender/blenkernel/intern/sound.c6
-rw-r--r--source/blender/blenkernel/intern/suggestions.c18
-rw-r--r--source/blender/blenkernel/intern/texture.c134
-rw-r--r--source/blender/blenkernel/intern/unit.c8
-rw-r--r--source/blender/blenkernel/intern/world.c11
60 files changed, 1882 insertions, 1356 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index 35ba8caedb0..8c265a1f8c9 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -397,7 +397,7 @@ static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) {
(e->v1==v && e->v0==vQ))
return e;
}
- return 0;
+ return NULL;
}
static int _vert_isBoundary(CCGVert *v) {
int i;
@@ -599,7 +599,7 @@ static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int e
static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset) {
return (float*) ((byte*) _face_getIFCoEdge(f, e, lvl, eX, eY, levels, dataSize) + normalDataOffset);
}
-void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize) {
+static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize) {
float *a = _face_getIFCo(f, lvl, S, x+0, y+0, levels, dataSize);
float *b = _face_getIFCo(f, lvl, S, x+1, y+0, levels, dataSize);
float *c = _face_getIFCo(f, lvl, S, x+1, y+1, levels, dataSize);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 658d29f0046..eedc2636991 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -432,7 +432,7 @@ void DM_swap_face_data(DerivedMesh *dm, int index, const int *corner_indices)
///
-static DerivedMesh *getMeshDerivedMesh(Mesh *me, Object *ob, float (*vertCos)[3])
+DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3])
{
DerivedMesh *dm = CDDM_from_mesh(me, ob);
@@ -1122,8 +1122,7 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r)
vert_r->no[1] = ev->no[1] * 32767.0;
vert_r->no[2] = ev->no[2] * 32767.0;
- /* TODO what to do with vert_r->flag and vert_r->mat_nr? */
- vert_r->mat_nr = 0;
+ /* TODO what to do with vert_r->flag? */
vert_r->bweight = (unsigned char) (ev->bweight*255.0f);
}
@@ -1220,8 +1219,7 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r)
vert_r->no[1] = ev->no[1] * 32767.0;
vert_r->no[2] = ev->no[2] * 32767.0;
- /* TODO what to do with vert_r->flag and vert_r->mat_nr? */
- vert_r->mat_nr = 0;
+ /* TODO what to do with vert_r->flag? */
vert_r->flag = 0;
vert_r->bweight = (unsigned char) (ev->bweight*255.0f);
}
@@ -1332,7 +1330,7 @@ static void emDM_release(DerivedMesh *dm)
}
}
-static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, float (*vertexCos)[3])
+DerivedMesh *editmesh_get_derived(EditMesh *em, float (*vertexCos)[3])
{
EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm");
@@ -1449,11 +1447,11 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, Modifier
float (*deformedVerts)[3] = mesh_getVertexCos(me, &numVerts);
mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, 0, 0);
- dm = getMeshDerivedMesh(me, ob, deformedVerts);
+ dm = mesh_create_derived(me, ob, deformedVerts);
MEM_freeN(deformedVerts);
} else {
- DerivedMesh *tdm = getMeshDerivedMesh(me, ob, NULL);
+ DerivedMesh *tdm = mesh_create_derived(me, ob, NULL);
dm = mti->applyModifier(md, ob, tdm, 0, 0);
if(tdm != dm) tdm->release(tdm);
@@ -1723,12 +1721,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
if(mti->type == eModifierTypeType_OnlyDeform) {
- if(sculpt_mode && !has_multires)
- if(!ELEM(md->type, eModifierType_Armature, eModifierType_ShapeKey)) {
- modifier_setError(md, "Not supported in sculpt mode.");
- continue;
- }
-
if(!deformedVerts)
deformedVerts = mesh_getVertexCos(me, &numVerts);
@@ -1782,7 +1774,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
continue;
}
if(sculpt_mode && (!has_multires || multires_applied))
- if(md->type != eModifierType_Armature || multires_applied) {
+ if(mti->type != eModifierTypeType_OnlyDeform || multires_applied) {
modifier_setError(md, "Not supported in sculpt mode.");
continue;
}
@@ -2005,7 +1997,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
BLI_linklist_free(datamasks, NULL);
}
-static float (*editmesh_getVertexCos(EditMesh *em, int *numVerts_r))[3]
+float (*editmesh_get_vertex_cos(EditMesh *em, int *numVerts_r))[3]
{
int i, numVerts = *numVerts_r = BLI_countlist(&em->verts);
float (*cos)[3];
@@ -2019,7 +2011,7 @@ static float (*editmesh_getVertexCos(EditMesh *em, int *numVerts_r))[3]
return cos;
}
-static int editmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm)
+int editmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm)
{
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
@@ -2048,7 +2040,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri
modifiers_clearErrors(ob);
if(cage_r && cageIndex == -1) {
- *cage_r = getEditMeshDerivedMesh(em, NULL);
+ *cage_r = editmesh_get_derived(em, NULL);
}
dm = NULL;
@@ -2090,7 +2082,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri
MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv");
dm->getVertCos(dm, deformedVerts);
} else {
- deformedVerts = editmesh_getVertexCos(em, &numVerts);
+ deformedVerts = editmesh_get_vertex_cos(em, &numVerts);
}
}
@@ -2180,7 +2172,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri
*cage_r = dm;
} else {
*cage_r =
- getEditMeshDerivedMesh(em,
+ editmesh_get_derived(em,
deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
}
}
@@ -2204,7 +2196,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri
} else if (!deformedVerts && cage_r && *cage_r) {
*final_r = *cage_r;
} else {
- *final_r = getEditMeshDerivedMesh(em, deformedVerts);
+ *final_r = editmesh_get_derived(em, deformedVerts);
deformedVerts = NULL;
}
@@ -2427,7 +2419,7 @@ DerivedMesh *editmesh_get_derived_cage(Scene *scene, Object *obedit, EditMesh *e
DerivedMesh *editmesh_get_derived_base(Object *UNUSED(obedit), EditMesh *em)
{
- return getEditMeshDerivedMesh(em, NULL);
+ return editmesh_get_derived(em, NULL);
}
@@ -2487,105 +2479,6 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
return vertexcosnos;
}
-/* ********* crazyspace *************** */
-
-int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3])
-{
- ModifierData *md;
- DerivedMesh *dm;
- int i, a, numleft = 0, numVerts = 0;
- int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
- float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL;
-
- modifiers_clearErrors(ob);
-
- dm = NULL;
- md = modifiers_getVirtualModifierList(ob);
-
- /* compute the deformation matrices and coordinates for the first
- modifiers with on cage editing that are enabled and support computing
- deform matrices */
- for(i = 0; md && i <= cageIndex; i++, md = md->next) {
- ModifierTypeInfo *mti = modifierType_getInfo(md->type);
-
- if(!editmesh_modifier_is_enabled(scene, md, dm))
- continue;
-
- if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
- if(!defmats) {
- dm= getEditMeshDerivedMesh(em, NULL);
- deformedVerts= editmesh_getVertexCos(em, &numVerts);
- defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
-
- for(a=0; a<numVerts; a++)
- unit_m3(defmats[a]);
- }
-
- mti->deformMatricesEM(md, ob, em, dm, deformedVerts, defmats,
- numVerts);
- }
- else
- break;
- }
-
- for(; md && i <= cageIndex; md = md->next, i++)
- if(editmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md))
- numleft++;
-
- if(dm)
- dm->release(dm);
-
- *deformmats= defmats;
- *deformcos= deformedVerts;
-
- return numleft;
-}
-
-void sculpt_get_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3])
-{
- ModifierData *md;
- DerivedMesh *dm;
- int a, numVerts= 0;
- float (*defmats)[3][3]= NULL, (*deformedVerts)[3]= NULL;
- MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0);
- int has_multires = mmd != NULL && mmd->sculptlvl > 0;
-
- if(has_multires) {
- *deformmats= NULL;
- *deformcos= NULL;
- return;
- }
-
- dm= NULL;
- md= modifiers_getVirtualModifierList(ob);
-
- for(; md; md= md->next) {
- ModifierTypeInfo *mti= modifierType_getInfo(md->type);
-
- if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue;
-
- if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatrices) {
- if(!defmats) {
- Mesh *me= (Mesh*)ob->data;
- dm= getMeshDerivedMesh(me, ob, NULL);
- deformedVerts= mesh_getVertexCos(me, &numVerts);
- defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats");
-
- for(a=0; a<numVerts; a++)
- unit_m3(defmats[a]);
- }
-
- mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts);
- }
- }
-
- if(dm)
- dm->release(dm);
-
- *deformmats= defmats;
- *deformcos= deformedVerts;
-}
-
/* ******************* GLSL ******************** */
void DM_add_tangent_layer(DerivedMesh *dm)
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 3bfdbdc4fc9..328f2ccdc75 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -93,11 +93,11 @@ void make_local_action(bAction *act)
bAction *actn;
int local=0, lib=0;
- if (act->id.lib==0) return;
+ if (act->id.lib==NULL) return;
if (act->id.us==1) {
- act->id.lib= 0;
+ act->id.lib= NULL;
act->id.flag= LIB_LOCAL;
- new_id(0, (ID *)act, 0);
+ new_id(NULL, (ID *)act, NULL);
return;
}
@@ -113,10 +113,10 @@ void make_local_action(bAction *act)
#endif
if(local && lib==0) {
- act->id.lib= 0;
+ act->id.lib= NULL;
act->id.flag= LIB_LOCAL;
//make_local_action_channels(act);
- new_id(0, (ID *)act, 0);
+ new_id(NULL, (ID *)act, NULL);
}
else if(local && lib) {
actn= copy_action(act);
@@ -1144,7 +1144,7 @@ void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose
animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe);
}
else {
- AnimData adt= {0};
+ AnimData adt= {NULL};
/* init animdata, and attach to workob */
workob->adt= &adt;
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index ab1da04e683..8fdfca33efb 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -64,6 +64,7 @@
#include "BKE_scene.h"
#include "BKE_utildefines.h"
#include "BKE_depsgraph.h"
+#include "BKE_anim.h"
// XXX bad level call...
@@ -1159,12 +1160,12 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated)
{
GroupObject *go;
- Object *ob=0, **oblist=0, obcopy, *obcopylist=0;
+ Object *ob=NULL, **oblist=NULL, obcopy, *obcopylist=NULL;
DupliObject *dob;
ParticleDupliWeight *dw;
ParticleSettings *part;
ParticleData *pa;
- ChildParticle *cpa=0;
+ ChildParticle *cpa=NULL;
ParticleKey state;
ParticleCacheKey *cache;
float ctime, pa_time, scale = 1.0f;
@@ -1173,18 +1174,23 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
int a, b, counter, hair = 0;
int totpart, totchild, totgroup=0, pa_num;
- if(psys==0) return;
+ int no_draw_flag = PARS_UNEXIST;
+
+ if(psys==NULL) return;
/* simple preventing of too deep nested groups */
if(level>MAX_DUPLI_RECUR) return;
part=psys->part;
- if(part==0)
+ if(part==NULL)
return;
if(!psys_check_enabled(par, psys))
return;
+
+ if(G.rendering == 0)
+ no_draw_flag |= PARS_NO_DISP;
ctime = bsystem_time(scene, par, (float)scene->r.cfra, 0.0);
@@ -1194,7 +1200,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
BLI_srandom(31415926 + psys->seed);
if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
- ParticleSimulationData sim= {0};
+ ParticleSimulationData sim= {NULL};
sim.scene= scene;
sim.ob= par;
sim.psys= psys;
@@ -1280,7 +1286,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
for(pa=psys->particles,counter=0; a<totpart+totchild; a++,pa++,counter++) {
if(a<totpart) {
/* handle parent particle */
- if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP))
+ if(pa->flag & no_draw_flag)
continue;
pa_num = pa->num;
@@ -1293,7 +1299,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
pa_num = a;
pa_time = psys->particles[cpa->parent].time;
- size = psys_get_child_size(psys, cpa, ctime, 0);
+ size = psys_get_child_size(psys, cpa, ctime, NULL);
}
/* some hair paths might be non-existent so they can't be used for duplication */
@@ -1324,11 +1330,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
/* hair we handle separate and compute transform based on hair keys */
if(a < totpart) {
cache = psys->pathcache[a];
- psys_get_dupli_path_transform(&sim, pa, 0, cache, pamat, &scale);
+ psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale);
}
else {
cache = psys->childcache[a-totpart];
- psys_get_dupli_path_transform(&sim, 0, cpa, cache, pamat, &scale);
+ psys_get_dupli_path_transform(&sim, NULL, cpa, cache, pamat, &scale);
}
VECCOPY(pamat[3], cache->co);
@@ -1444,7 +1450,7 @@ static Object *find_family_object(Object **obar, char *family, char ch)
static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated)
{
- Object *ob, *obar[256]= {0};
+ Object *ob, *obar[256]= {NULL};
Curve *cu;
struct chartrans *ct, *chartransdata;
float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;
@@ -1458,7 +1464,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i
/* in par the family name is stored, use this to find the other objects */
chartransdata= BKE_text_to_curve(scene, par, FO_DUPLI);
- if(chartransdata==0) return;
+ if(chartransdata==NULL) return;
cu= par->data;
slen= strlen(cu->str);
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index fcce85b026e..dead11c692c 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -816,7 +816,7 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[]
eq_id= 0;
/* path */
- if ((ksp->rna_path==0) || strcmp(rna_path, ksp->rna_path))
+ if ((ksp->rna_path==NULL) || strcmp(rna_path, ksp->rna_path))
eq_path= 0;
/* index - need to compare whole-array setting too... */
@@ -1863,7 +1863,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
/* if there are strips, evaluate action as per NLA rules */
if ((has_strips) || (adt->actstrip)) {
/* make dummy NLA strip, and add that to the stack */
- NlaStrip dummy_strip= {0};
+ NlaStrip dummy_strip= {NULL};
ListBase dummy_trackslist;
dummy_trackslist.first= dummy_trackslist.last= &dummy_strip;
@@ -1922,11 +1922,13 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime)
/* Clear all overides */
/* Add or get existing Override for given setting */
+#if 0
AnimOverride *BKE_animsys_validate_override (PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index))
{
// FIXME: need to define how to get overrides
return NULL;
}
+#endif
/* -------------------- */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 14c4b6f97ab..cc01438fd5d 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -136,19 +136,19 @@ void make_local_armature(bArmature *arm)
Object *ob;
bArmature *newArm;
- if (arm->id.lib==0)
+ if (arm->id.lib==NULL)
return;
if (arm->id.us==1) {
- arm->id.lib= 0;
+ arm->id.lib= NULL;
arm->id.flag= LIB_LOCAL;
- new_id(0, (ID*)arm, 0);
+ new_id(NULL, (ID*)arm, NULL);
return;
}
if(local && lib==0) {
- arm->id.lib= 0;
+ arm->id.lib= NULL;
arm->id.flag= LIB_LOCAL;
- new_id(0, (ID *)arm, 0);
+ new_id(NULL, (ID *)arm, NULL);
}
else if(local && lib) {
newArm= copy_armature(arm);
@@ -158,7 +158,7 @@ void make_local_armature(bArmature *arm)
while(ob) {
if(ob->data==arm) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= newArm;
newArm->id.us++;
arm->id.us--;
@@ -248,16 +248,15 @@ Bone *get_named_bone (bArmature *arm, const char *name)
}
/* Finds the best possible extension to the name on a particular axis. (For renaming, check for unique names afterwards)
- * This assumes that bone names are at most 32 chars long!
* strip_number: removes number extensions (TODO: not used)
* axis: the axis to name on
* head/tail: the head/tail co-ordinate of the bone on the specified axis
*/
-int bone_autoside_name (char *name, int UNUSED(strip_number), short axis, float head, float tail)
+int bone_autoside_name (char name[MAXBONENAME], int UNUSED(strip_number), short axis, float head, float tail)
{
unsigned int len;
- char basename[32]={""};
- char extension[5]={""};
+ char basename[MAXBONENAME]= "";
+ char extension[5]= "";
len= strlen(name);
if (len == 0) return 0;
@@ -350,13 +349,13 @@ int bone_autoside_name (char *name, int UNUSED(strip_number), short axis, float
}
}
}
-
- if ((32 - len) < strlen(extension) + 1) { /* add 1 for the '.' */
+
+ if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */
strncpy(name, basename, len-strlen(extension));
}
-
- sprintf(name, "%s.%s", basename, extension);
-
+
+ BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension);
+
return 1;
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 6e08df0f465..e34b4bef8d4 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -88,10 +88,10 @@
Global G;
UserDef U;
-ListBase WMlist= {NULL, NULL};
+/* ListBase = {NULL, NULL}; */
short ENDIAN_ORDER;
-char versionstr[48]= "";
+static char versionstr[48]= "";
/* ********** free ********** */
@@ -124,9 +124,9 @@ void initglobals(void)
ENDIAN_ORDER= (((char*)&ENDIAN_ORDER)[0])? L_ENDIAN: B_ENDIAN;
if(BLENDER_SUBVERSION)
- sprintf(versionstr, "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
+ BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
else
- sprintf(versionstr, "www.blender.org %d", BLENDER_VERSION);
+ BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d", BLENDER_VERSION);
#ifdef _WIN32 // FULLSCREEN
G.windowstate = G_WINDOWSTATE_USERDEF;
@@ -314,7 +314,7 @@ static int handle_subversion_warning(Main *main)
char str[128];
- sprintf(str, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
+ BLI_snprintf(str, sizeof(str), "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
// XXX error(str);
}
return 1;
@@ -350,7 +350,7 @@ int BKE_read_file(bContext *C, const char *dir, ReportList *reports)
BlendFileData *bfd;
int retval= 1;
- if(strstr(dir, BLENDER_STARTUP_FILE)==0) /* dont print user-pref loading */
+ if(strstr(dir, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */
printf("read blend: %s\n", dir);
bfd= BLO_read_from_file(dir, reports);
@@ -457,7 +457,7 @@ static int read_undosave(bContext *C, UndoElem *uel)
success= BKE_read_file_from_memfile(C, &uel->memfile, NULL);
/* restore */
- strcpy(G.main->name, mainstr); /* restore */
+ BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */
G.fileflags= fileflags;
if(success) {
@@ -520,12 +520,12 @@ void BKE_write_undo(bContext *C, const char *name)
counter++;
counter= counter % U.undosteps;
- sprintf(numstr, "%d.blend", counter);
+ BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_make_file_string("/", tstr, btempdir, numstr);
success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL);
- strcpy(curundo->str, tstr);
+ BLI_strncpy(curundo->str, tstr, sizeof(curundo->str));
}
else {
MemFile *prevfile=NULL;
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index e2a6c04450b..aa0669903c5 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -54,6 +54,7 @@
#include "BKE_global.h"
#include "IMB_imbuf_types.h"
+#include "BKE_bmfont.h"
#include "BKE_bmfont_types.h"
void printfGlyph(bmGlyph * glyph)
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 228827bab68..ae4882b0eca 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -1470,7 +1470,7 @@ BoidRule *boid_new_rule(int type)
rule->type = type;
rule->flag |= BOIDRULE_IN_AIR|BOIDRULE_ON_LAND;
- strcpy(rule->name, boidrule_type_items[type-1].name);
+ BLI_strncpy(rule->name, boidrule_type_items[type-1].name, sizeof(rule->name));
return rule;
}
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index b1931ebe0a7..4ad3b8bb3cf 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -186,13 +186,13 @@ void make_local_brush(Brush *brush)
Scene *scene;
int local= 0, lib= 0;
- if(brush->id.lib==0) return;
+ if(brush->id.lib==NULL) return;
if(brush->clone.image) {
/* special case: ima always local immediately */
- brush->clone.image->id.lib= 0;
+ brush->clone.image->id.lib= NULL;
brush->clone.image->id.flag= LIB_LOCAL;
- new_id(0, (ID *)brush->clone.image, 0);
+ new_id(NULL, (ID *)brush->clone.image, NULL);
}
for(scene= G.main->scene.first; scene; scene=scene->id.next)
@@ -202,9 +202,9 @@ void make_local_brush(Brush *brush)
}
if(local && lib==0) {
- brush->id.lib= 0;
+ brush->id.lib= NULL;
brush->id.flag= LIB_LOCAL;
- new_id(0, (ID *)brush, 0);
+ new_id(NULL, (ID *)brush, NULL);
/* enable fake user by default */
if (!(brush->id.flag & LIB_FAKEUSER)) {
@@ -219,7 +219,7 @@ void make_local_brush(Brush *brush)
for(scene= G.main->scene.first; scene; scene=scene->id.next)
if(paint_brush(&scene->toolsettings->imapaint.paint)==brush)
- if(scene->id.lib==0) {
+ if(scene->id.lib==NULL) {
paint_brush_set(&scene->toolsettings->imapaint.paint, brushn);
brushn->id.us++;
brush->id.us--;
@@ -227,10 +227,10 @@ void make_local_brush(Brush *brush)
}
}
-void brush_debug_print_state(Brush *br)
+static void brush_debug_print_state(Brush *br)
{
/* create a fake brush and set it to the defaults */
- Brush def= {{0}};
+ Brush def= {{NULL}};
brush_set_defaults(&def);
#define BR_TEST(field, t) \
@@ -424,7 +424,7 @@ int brush_texture_set_nr(Brush *brush, int nr)
id= (ID *)brush->mtex.tex;
idtest= (ID*)BLI_findlink(&G.main->tex, nr-1);
- if(idtest==0) { /* new tex */
+ if(idtest==NULL) { /* new tex */
if(id) idtest= (ID *)copy_texture((Tex *)id);
else idtest= (ID *)add_texture("Tex");
idtest->us--;
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 932be711938..abf2257877b 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -729,7 +729,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
GPU_vertex_setup( dm );
GPU_normal_setup( dm );
GPU_uv_setup( dm );
- if( col != 0 ) {
+ if( col != NULL ) {
/*if( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) {
col = 0;
} else if( mcol && dm->drawObject->colType == CD_MCOL ) {
@@ -983,7 +983,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
glShadeModel(GL_SMOOTH);
- if( GPU_buffer_legacy(dm) || setDrawOptions != 0 ) {
+ if( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) {
DEBUG_VBO( "Using legacy code. cdDM_drawMappedFacesGLSL\n" );
memset(&attribs, 0, sizeof(attribs));
@@ -1086,8 +1086,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
glEnd();
}
else {
- GPUBuffer *buffer = 0;
- char *varray = 0;
+ GPUBuffer *buffer = NULL;
+ char *varray = NULL;
int numdata = 0, elementsize = 0, offset;
int start = 0, numfaces = 0, prevdraw = 0, curface = 0;
int i;
@@ -1124,9 +1124,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
if( numdata != 0 ) {
- GPU_buffer_free(buffer,0);
+ GPU_buffer_free(buffer, NULL);
- buffer = 0;
+ buffer = NULL;
}
}
@@ -1164,16 +1164,16 @@ 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, 0 );
- if( buffer == 0 ) {
+ buffer = GPU_buffer_alloc( elementsize*dm->drawObject->nelements, NULL );
+ if( buffer == NULL ) {
GPU_buffer_unbind();
dm->drawObject->legacy = 1;
return;
}
varray = GPU_buffer_lock_stream(buffer);
- if( varray == 0 ) {
+ if( varray == NULL ) {
GPU_buffer_unbind();
- GPU_buffer_free(buffer, 0);
+ GPU_buffer_free(buffer, NULL);
dm->drawObject->legacy = 1;
return;
}
@@ -1312,7 +1312,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo
}
GPU_buffer_unbind();
}
- GPU_buffer_free( buffer, 0 );
+ GPU_buffer_free( buffer, NULL );
}
glShadeModel(GL_FLAT);
@@ -1604,7 +1604,6 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me))
mv->no[2] = eve->no[2] * 32767.0;
mv->bweight = (unsigned char) (eve->bweight * 255.0f);
- mv->mat_nr = 0;
mv->flag = 0;
*index = i;
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 8cdfd60b9a7..02b3de83ee1 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -164,8 +164,8 @@ Collision modifier code end
*/
#define mySWAP(a,b) do { double tmp = b ; b = a ; a = tmp ; } while(0)
-
-int
+#if 0 /* UNUSED */
+static int
gsl_poly_solve_cubic (double a, double b, double c,
double *x0, double *x1, double *x2)
{
@@ -255,7 +255,7 @@ gsl_poly_solve_cubic (double a, double b, double c,
*
* copied from GSL
*/
-int
+static int
gsl_poly_solve_quadratic (double a, double b, double c,
double *x0, double *x1)
{
@@ -313,7 +313,7 @@ gsl_poly_solve_quadratic (double a, double b, double c,
return 0;
}
}
-
+#endif /* UNUSED */
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index c61f3ba3683..b3f83019ff1 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -419,7 +419,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, char *substring, float mat[][4])
+static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4])
{
DerivedMesh *dm = NULL;
Mesh *me= ob->data;
@@ -524,7 +524,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f
}
/* function that sets the given matrix based on given vertex group in lattice */
-static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][4])
+static void contarget_get_lattice_mat (Object *ob, const char *substring, float mat[][4])
{
Lattice *lt= (Lattice *)ob->data;
@@ -582,7 +582,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][
/* 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, char *substring, float mat[][4], short from, short to, float headtail)
+static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail)
{
/* Case OBJECT */
if (!strlen(substring)) {
@@ -752,7 +752,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain
bConstraintTarget *ctn = ct->next; \
if (nocopy == 0) { \
datatar= ct->tar; \
- strcpy(datasubtarget, ct->subtarget); \
+ BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \
con->tarspace= (char)ct->space; \
} \
\
@@ -834,54 +834,71 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
/* only evaluate if there is a target */
if (VALID_CONS_TARGET(ct)) {
- float parmat[4][4], invmat[4][4], tempmat[4][4];
- float loc[3], eul[3], size[3];
- float loco[3], eulo[3], sizo[3];
-
- /* get offset (parent-inverse) matrix */
- copy_m4_m4(invmat, data->invmat);
-
- /* extract components of both matrices */
- copy_v3_v3(loc, ct->matrix[3]);
- mat4_to_eulO(eul, ct->rotOrder, ct->matrix);
- mat4_to_size(size, ct->matrix);
+ float parmat[4][4];
- copy_v3_v3(loco, invmat[3]);
- mat4_to_eulO(eulo, cob->rotOrder, invmat);
- mat4_to_size(sizo, invmat);
-
- /* disable channels not enabled */
- if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f;
- if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f;
- if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f;
- if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f;
- if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f;
- if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f;
- if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f;
- if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f;
- if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f;
-
- /* make new target mat and offset mat */
- loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder);
- loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder);
-
- /* multiply target (parent matrix) by offset (parent inverse) to get
- * the effect of the parent that will be exherted on the owner
- */
- mul_m4_m4m4(parmat, invmat, ct->matrix);
-
- /* now multiply the parent matrix by the owner matrix to get the
- * the effect of this constraint (i.e. owner is 'parented' to parent)
- */
- copy_m4_m4(tempmat, cob->matrix);
- mul_m4_m4m4(cob->matrix, tempmat, parmat);
-
- /* without this, changes to scale and rotation can change location
- * of a parentless bone or a disconnected bone. Even though its set
- * to zero above. */
- if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0];
- if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1];
- if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2];
+ /* simple matrix parenting */
+ if(data->flag == CHILDOF_ALL) {
+
+ /* multiply target (parent matrix) by offset (parent inverse) to get
+ * the effect of the parent that will be exherted on the owner
+ */
+ mul_m4_m4m4(parmat, data->invmat, ct->matrix);
+
+ /* now multiply the parent matrix by the owner matrix to get the
+ * the effect of this constraint (i.e. owner is 'parented' to parent)
+ */
+ mul_m4_m4m4(cob->matrix, cob->matrix, parmat);
+ }
+ else {
+ float invmat[4][4], tempmat[4][4];
+ float loc[3], eul[3], size[3];
+ float loco[3], eulo[3], sizo[3];
+
+ /* get offset (parent-inverse) matrix */
+ copy_m4_m4(invmat, data->invmat);
+
+ /* extract components of both matrices */
+ copy_v3_v3(loc, ct->matrix[3]);
+ mat4_to_eulO(eul, ct->rotOrder, ct->matrix);
+ mat4_to_size(size, ct->matrix);
+
+ copy_v3_v3(loco, invmat[3]);
+ mat4_to_eulO(eulo, cob->rotOrder, invmat);
+ mat4_to_size(sizo, invmat);
+
+ /* disable channels not enabled */
+ if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f;
+ if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f;
+ if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f;
+ if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f;
+ if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f;
+ if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f;
+ if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f;
+ if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f;
+ if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f;
+
+ /* make new target mat and offset mat */
+ loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder);
+ loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder);
+
+ /* multiply target (parent matrix) by offset (parent inverse) to get
+ * the effect of the parent that will be exherted on the owner
+ */
+ mul_m4_m4m4(parmat, invmat, ct->matrix);
+
+ /* now multiply the parent matrix by the owner matrix to get the
+ * the effect of this constraint (i.e. owner is 'parented' to parent)
+ */
+ copy_m4_m4(tempmat, cob->matrix);
+ mul_m4_m4m4(cob->matrix, tempmat, parmat);
+
+ /* without this, changes to scale and rotation can change location
+ * of a parentless bone or a disconnected bone. Even though its set
+ * to zero above. */
+ if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0];
+ if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1];
+ if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2];
+ }
}
}
@@ -3452,7 +3469,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
BVHTreeRayHit hit;
BVHTreeNearest nearest;
- BVHTreeFromMesh treeData= {0};
+ BVHTreeFromMesh treeData= {NULL};
nearest.index = -1;
nearest.dist = FLT_MAX;
@@ -4131,6 +4148,21 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c
constraints_set_active(list, con);
}
+ /* set type+owner specific immutable settings */
+ // TODO: does action constraint need anything here - i.e. spaceonce?
+ switch (type) {
+ case CONSTRAINT_TYPE_CHILDOF:
+ {
+ /* if this constraint is being added to a posechannel, make sure
+ * the constraint gets evaluated in pose-space */
+ if (pchan) {
+ con->ownspace = CONSTRAINT_SPACE_POSE;
+ con->flag |= CONSTRAINT_SPACEONCE;
+ }
+ }
+ break;
+ }
+
return con;
}
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 09321ddea81..58a7944f78b 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -85,7 +85,7 @@ struct bContext {
/* context */
-bContext *CTX_create()
+bContext *CTX_create(void)
{
bContext *C;
@@ -788,7 +788,7 @@ static const char *data_mode_strings[] = {
"texturepaint",
"particlemode",
"objectmode",
- 0
+ NULL
};
const char *CTX_data_mode_string(const bContext *C)
{
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 2678b077b66..5dc62f2c7af 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -174,7 +174,7 @@ Curve *copy_curve(Curve *cu)
int a;
cun= copy_libblock(cu);
- cun->nurb.first= cun->nurb.last= 0;
+ cun->nurb.first= cun->nurb.last= NULL;
duplicateNurblist( &(cun->nurb), &(cu->nurb));
cun->mat= MEM_dupallocN(cu->mat);
@@ -190,9 +190,9 @@ Curve *copy_curve(Curve *cu)
cun->key= copy_key(cu->key);
if(cun->key) cun->key->from= (ID *)cun;
- cun->disp.first= cun->disp.last= 0;
- cun->bev.first= cun->bev.last= 0;
- cun->path= 0;
+ cun->disp.first= cun->disp.last= NULL;
+ cun->bev.first= cun->bev.last= NULL;
+ cun->path= NULL;
cun->editnurb= NULL;
cun->editfont= NULL;
@@ -212,7 +212,7 @@ Curve *copy_curve(Curve *cu)
void make_local_curve(Curve *cu)
{
- Object *ob = 0;
+ Object *ob = NULL;
Curve *cun;
int local=0, lib=0;
@@ -221,7 +221,7 @@ void make_local_curve(Curve *cu)
* - mixed: do a copy
*/
- if(cu->id.lib==0) return;
+ if(cu->id.lib==NULL) return;
if(cu->vfont) cu->vfont->id.lib= NULL;
if(cu->vfontb) cu->vfontb->id.lib= NULL;
@@ -229,9 +229,9 @@ void make_local_curve(Curve *cu)
if(cu->vfontbi) cu->vfontbi->id.lib= NULL;
if(cu->id.us==1) {
- cu->id.lib= 0;
+ cu->id.lib= NULL;
cu->id.flag= LIB_LOCAL;
- new_id(0, (ID *)cu, 0);
+ new_id(NULL, (ID *)cu, NULL);
return;
}
@@ -245,9 +245,9 @@ void make_local_curve(Curve *cu)
}
if(local && lib==0) {
- cu->id.lib= 0;
+ cu->id.lib= NULL;
cu->id.flag= LIB_LOCAL;
- new_id(0, (ID *)cu, 0);
+ new_id(NULL, (ID *)cu, NULL);
}
else if(local && lib) {
cun= copy_curve(cu);
@@ -257,7 +257,7 @@ void make_local_curve(Curve *cu)
while(ob) {
if(ob->data==cu) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= cun;
cun->id.us++;
cu->id.us--;
@@ -381,12 +381,12 @@ int count_curveverts_without_handles(ListBase *nurb)
void freeNurb(Nurb *nu)
{
- if(nu==0) return;
+ if(nu==NULL) return;
if(nu->bezt) MEM_freeN(nu->bezt);
- nu->bezt= 0;
+ nu->bezt= NULL;
if(nu->bp) MEM_freeN(nu->bp);
- nu->bp= 0;
+ nu->bp= NULL;
if(nu->knotsu) MEM_freeN(nu->knotsu);
nu->knotsu= NULL;
if(nu->knotsv) MEM_freeN(nu->knotsv);
@@ -402,7 +402,7 @@ void freeNurblist(ListBase *lb)
{
Nurb *nu, *next;
- if(lb==0) return;
+ if(lb==NULL) return;
nu= lb->first;
while(nu) {
@@ -410,7 +410,7 @@ void freeNurblist(ListBase *lb)
freeNurb(nu);
nu= next;
}
- lb->first= lb->last= 0;
+ lb->first= lb->last= NULL;
}
Nurb *duplicateNurb(Nurb *nu)
@@ -419,7 +419,7 @@ Nurb *duplicateNurb(Nurb *nu)
int len;
newnu= (Nurb*)MEM_mallocN(sizeof(Nurb),"duplicateNurb");
- if(newnu==0) return 0;
+ if(newnu==NULL) return NULL;
memcpy(newnu, nu, sizeof(Nurb));
if(nu->bezt) {
@@ -615,7 +615,7 @@ static void makecyclicknots(float *knots, short pnts, short order)
{
int a, b, order2, c;
- if(knots==0) return;
+ if(knots==NULL) return;
order2=order-1;
@@ -918,7 +918,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu
if(nu->knotsu==NULL) return;
if(nu->orderu>nu->pntsu) return;
- if(coord_array==0) return;
+ if(coord_array==NULL) return;
/* allocate and initialize */
len= nu->pntsu;
@@ -1269,7 +1269,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender)
dl= bevdisp.first;
} else {
dl= cu->bevobj->disp.first;
- if(dl==0) {
+ if(dl==NULL) {
makeDispListCurveTypes(scene, cu->bevobj, 0);
dl= cu->bevobj->disp.first;
}
@@ -1811,8 +1811,6 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
int nr;
float q[4];
- float cross_tmp[3];
-
bevel_list_calc_bisect(bl);
bevp2= (BevPoint *)(bl+1);
@@ -1829,6 +1827,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl)
float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir);
if(angle > 0.0f) { /* otherwise we can keep as is */
+ float cross_tmp[3];
cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir);
axis_angle_to_quat(q, cross_tmp, angle);
mul_qt_qtqt(bevp1->quat, q, bevp0->quat);
@@ -2426,7 +2425,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
p2= bezt->vec[1];
- if(prev==0) {
+ if(prev==NULL) {
p3= next->vec[1];
pt[0]= 2*p2[0]- p3[0];
pt[1]= 2*p2[1]- p3[1];
@@ -2435,7 +2434,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
}
else p1= prev->vec[1];
- if(next==0) {
+ if(next==NULL) {
pt[0]= 2*p2[0]- p1[0];
pt[1]= 2*p2[1]- p1[1];
pt[2]= 2*p2[2]- p1[2];
@@ -2616,7 +2615,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
a= nu->pntsu;
bezt= nu->bezt;
if(nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1);
- else prev= 0;
+ else prev= NULL;
next= bezt+1;
while(a--) {
@@ -2624,7 +2623,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */
prev= bezt;
if(a==1) {
if(nu->flagu & CU_NURB_CYCLIC) next= nu->bezt;
- else next= 0;
+ else next= NULL;
}
else next++;
@@ -2683,7 +2682,7 @@ void autocalchandlesNurb(Nurb *nu, int flag)
BezTriple *bezt2, *bezt1, *bezt0;
int i, align, leftsmall, rightsmall;
- if(nu==0 || nu->bezt==0) return;
+ if(nu==NULL || nu->bezt==NULL) return;
bezt2 = nu->bezt;
bezt1 = bezt2 + (nu->pntsu-1);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 94bb771aecd..7788f9f28a2 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -469,19 +469,19 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
vindex[x] = y;
for(i = 0; i < 2; i++) {
- float sw[4][4] = {{0}};
+ float sw_m4[4][4] = {{0}};
int a = 7 & ~(1 << vindex[i*2] | 1 << vindex[i*2+1]);
- sw[0][vindex[i*2+1]] = 1;
- sw[1][vindex[i*2]] = 1;
+ sw_m4[0][vindex[i*2+1]] = 1;
+ sw_m4[1][vindex[i*2]] = 1;
for(x = 0; x < 3; x++)
if(a & (1 << x))
- sw[2][x] = 1;
+ sw_m4[2][x] = 1;
tris[i] = *((MDisps*)sources[i]);
tris[i].disps = MEM_dupallocN(tris[i].disps);
- layerInterp_mdisps(&sources[i], NULL, (float*)sw, 1, &tris[i]);
+ layerInterp_mdisps(&sources[i], NULL, (float*)sw_m4, 1, &tris[i]);
}
mdisp_join_tris(d, &tris[0], &tris[1]);
@@ -524,8 +524,8 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights),
mdisp_apply_weight(S, dst_corners, side-1, 0, st, crn_weight, &axis_x[0], &axis_x[1]);
mdisp_apply_weight(S, dst_corners, 0, side-1, st, crn_weight, &axis_y[0], &axis_y[1]);
- sub_v3_v3(axis_x, base);
- sub_v3_v3(axis_y, base);
+ sub_v2_v2(axis_x, base);
+ sub_v2_v2(axis_y, base);
normalize_v2(axis_x);
normalize_v2(axis_y);
@@ -803,7 +803,7 @@ static void layerDefault_mcol(void *data, int count)
-const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
+static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL},
{sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL,
NULL},
@@ -842,7 +842,7 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
{sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}
};
-const char *LAYERTYPENAMES[CD_NUMTYPES] = {
+static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
/* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace",
/* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
/* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco",
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 937681fcdc3..7967013c2d4 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -50,7 +50,7 @@ void defgroup_copy_list (ListBase *outbase, ListBase *inbase)
{
bDeformGroup *defgroup, *defgroupn;
- outbase->first= outbase->last= 0;
+ outbase->first= outbase->last= NULL;
for (defgroup = inbase->first; defgroup; defgroup=defgroup->next){
defgroupn= defgroup_duplicate(defgroup);
@@ -335,33 +335,34 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob)
}
/* finds the best possible flipped name. For renaming; check for unique names afterwards */
-/* if strip_number: removes number extensions */
-void flip_side_name (char *name, const char *from_name, int strip_number)
+/* if strip_number: removes number extensions
+ * note: dont use sizeof() for 'name' or 'from_name' */
+void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
{
int len;
- char prefix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part before the facing */
- char suffix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part after the facing */
- char replace[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The replacement string */
- char number[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The number extension string */
+ char prefix[MAX_VGROUP_NAME]= ""; /* The part before the facing */
+ char suffix[MAX_VGROUP_NAME]= ""; /* The part after the facing */
+ char replace[MAX_VGROUP_NAME]= ""; /* The replacement string */
+ char number[MAX_VGROUP_NAME]= ""; /* The number extension string */
char *index=NULL;
- len= strlen(from_name);
+ len= BLI_strnlen(from_name, MAX_VGROUP_NAME);
if(len<3) return; // we don't do names like .R or .L
- strcpy(name, from_name);
+ BLI_strncpy(name, from_name, MAX_VGROUP_NAME);
/* We first check the case with a .### extension, let's find the last period */
if(isdigit(name[len-1])) {
index= strrchr(name, '.'); // last occurrence
if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever!
if(strip_number==0)
- strcpy(number, index);
+ BLI_strncpy(number, index, sizeof(number));
*index= 0;
- len= strlen(name);
+ len= BLI_strnlen(name, MAX_VGROUP_NAME);
}
}
- strcpy (prefix, name);
+ BLI_strncpy(prefix, name, sizeof(prefix));
#define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_')
@@ -445,7 +446,7 @@ void flip_side_name (char *name, const char *from_name, int strip_number)
#undef IS_SEPARATOR
- sprintf (name, "%s%s%s%s", prefix, replace, suffix, number);
+ BLI_snprintf (name, MAX_VGROUP_NAME, "%s%s%s%s", prefix, replace, suffix, number);
}
float defvert_find_weight(const struct MDeformVert *dvert, const int group_num)
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index cedf4e93247..d102a83d69f 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -40,7 +40,9 @@
#include "DNA_group_types.h"
#include "DNA_lattice_types.h"
#include "DNA_key_types.h"
+#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
+#include "DNA_node_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_windowmanager_types.h"
@@ -54,6 +56,7 @@
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_main.h"
+#include "BKE_node.h"
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
@@ -275,7 +278,7 @@ int queue_count(struct DagNodeQueue *queue){
}
-DagForest * dag_init()
+DagForest *dag_init(void)
{
DagForest *forest;
/* use callocN to init all zero */
@@ -1077,7 +1080,7 @@ void graph_bfs(void)
minheight = pos[node->BFS_dist];
itA = node->child;
while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) ) {
+ if(itA->node->color == DAG_WHITE) {
itA->node->color = DAG_GRAY;
itA->node->BFS_dist = node->BFS_dist + 1;
itA->node->k = (float) minheight;
@@ -1224,7 +1227,7 @@ DagNodeQueue * graph_dfs(void)
itA = node->child;
while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) ) {
+ if(itA->node->color == DAG_WHITE) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1478,7 +1481,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob)
itA = node->child;
while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) ) {
+ if(itA->node->color == DAG_WHITE) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1512,7 +1515,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) {
itA = node->child;
while(itA != NULL) {
- if((itA->node->ob == ob2) ) {
+ if(itA->node->ob == ob2) {
return itA->node->type;
}
itA = itA->next;
@@ -1684,7 +1687,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce)
itA = node->child;
while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) ) {
+ if(itA->node->color == DAG_WHITE) {
itA->node->DFS_dvtm = time;
itA->node->color = DAG_GRAY;
@@ -1923,6 +1926,28 @@ static void dag_scene_flush_layers(Scene *sce, int lay)
flush_layer_node(sce, itA->node, lasttime);
}
+static void dag_tag_renderlayers(Scene *sce, unsigned int lay)
+{
+ if(sce->nodetree) {
+ bNode *node;
+ Base *base;
+ unsigned int lay_changed= 0;
+
+ for(base= sce->base.first; base; base= base->next)
+ if(base->lay & lay)
+ if(base->object->recalc)
+ lay_changed |= base->lay;
+
+ for(node= sce->nodetree->nodes.first; node; node= node->next) {
+ if(node->id==(ID *)sce) {
+ SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1);
+ if(srl && (srl->lay & lay_changed))
+ NodeTagChanged(sce->nodetree, node);
+ }
+ }
+ }
+}
+
/* flushes all recalc flags in objects down the dependency tree */
void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const short time)
{
@@ -1967,6 +1992,8 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho
}
}
}
+
+ dag_tag_renderlayers(sce, lay);
}
static int object_modifiers_use_time(Object *ob)
@@ -2349,6 +2376,29 @@ static void dag_id_flush_update(Scene *sce, ID *id)
modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data);
if (data.is_dependent)
obt->recalc |= OB_RECALC_DATA;
+
+ /* particle settings can use the texture as well */
+ if(obt->particlesystem.first) {
+ ParticleSystem *psys = obt->particlesystem.first;
+ MTex **mtexp, *mtex;
+ int a;
+ for(; psys; psys=psys->next) {
+ mtexp = psys->part->mtex;
+ for(a=0; a<MAX_MTEX; a++, mtexp++) {
+ mtex = *mtexp;
+ if(mtex && mtex->tex == (Tex*)id) {
+ obt->recalc |= OB_RECALC_DATA;
+
+ if(mtex->mapto & PAMAP_INIT)
+ psys->recalc |= PSYS_RECALC_RESET;
+ if(mtex->mapto & PAMAP_CHILD)
+ psys->recalc |= PSYS_RECALC_CHILD;
+
+ BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
+ }
+ }
+ }
+ }
}
}
@@ -2596,7 +2646,7 @@ void DAG_pose_sort(Object *ob)
itA = node->child;
while(itA != NULL) {
- if((itA->node->color == DAG_WHITE) ) {
+ if(itA->node->color == DAG_WHITE) {
itA->node->color = DAG_GRAY;
push_stack(nqueue,itA->node);
skip = 1;
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 3bb62f817cd..837c3bd8356 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -121,7 +121,7 @@ DispList *find_displist(ListBase *lb, int type)
dl= dl->next;
}
- return 0;
+ return NULL;
}
int displist_has_faces(ListBase *lb)
@@ -930,13 +930,13 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
{
EditVert *eve, *v1, *vlast;
EditFace *efa;
- DispList *dlnew=0, *dl;
+ DispList *dlnew=NULL, *dl;
float *f1;
int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0;
intptr_t totvert;
- if(dispbase==0) return;
- if(dispbase->first==0) return;
+ if(dispbase==NULL) return;
+ if(dispbase->first==NULL) return;
while(cont) {
cont= 0;
@@ -953,7 +953,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
/* make editverts and edges */
f1= dl->verts;
a= dl->nr;
- eve= v1= 0;
+ eve= v1= NULL;
while(a--) {
vlast= eve;
@@ -961,14 +961,14 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal)
eve= BLI_addfillvert(f1);
totvert++;
- if(vlast==0) v1= eve;
+ if(vlast==NULL) v1= eve;
else {
BLI_addfilledge(vlast, eve);
}
f1+=3;
}
- if(eve!=0 && v1!=0) {
+ if(eve!=NULL && v1!=NULL) {
BLI_addfilledge(eve, v1);
}
} else if (colnr<dl->col) {
@@ -1058,7 +1058,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
float *fp, *fp1;
int a, dpoly;
- front.first= front.last= back.first= back.last= 0;
+ front.first= front.last= back.first= back.last= NULL;
dl= dispbase->first;
while(dl) {
@@ -1944,7 +1944,7 @@ void imagestodisplist(void)
/* this is confusing, there's also min_max_object, appplying the obmat... */
static void boundbox_displist(Object *ob)
{
- BoundBox *bb=0;
+ BoundBox *bb=NULL;
float min[3], max[3];
DispList *dl;
float *vert;
@@ -1956,7 +1956,7 @@ static void boundbox_displist(Object *ob)
Curve *cu= ob->data;
int doit= 0;
- if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
+ if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
bb= cu->bb;
dl= ob->disp.first;
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index a79a5fddf00..ddfc58b7491 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -166,7 +166,7 @@ PartEff *give_parteff(Object *ob)
if(paf->type==EFF_PARTICLE) return paf;
paf= paf->next;
}
- return 0;
+ return NULL;
}
void free_effect(Effect *eff)
@@ -636,7 +636,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
if(eff->psys == point->psys && *efd->index == point->index)
;
else {
- ParticleSimulationData sim= {0};
+ ParticleSimulationData sim= {NULL};
sim.scene= eff->scene;
sim.ob= eff->ob;
sim.psys= eff->psys;
@@ -651,11 +651,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
// eff->flag |= PE_VELOCITY_TO_IMPULSE;
//}
- VECCOPY(efd->loc, state.co);
- VECCOPY(efd->nor, state.vel);
- if(real_velocity) {
- VECCOPY(efd->vel, state.vel);
- }
+ copy_v3_v3(efd->loc, state.co);
+
+ /* rather than use the velocity use rotated x-axis (defaults to velocity) */
+ efd->nor[0] = 1.f;
+ efd->nor[1] = efd->nor[2] = 0.f;
+ mul_qt_v3(state.rot, efd->nor);
+
+ if(real_velocity)
+ copy_v3_v3(efd->vel, state.vel);
efd->size = pa->size;
}
@@ -720,7 +724,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
return ret;
}
-static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p)
+static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step)
{
if(eff->pd->shape == PFIELD_SHAPE_POINTS) {
efd->index = p;
@@ -753,6 +757,13 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin
*p= point->index % eff->psys->totpart;
*tot= *p + 1;
}
+
+ if(eff->psys->part->effector_amount) {
+ int totpart = eff->psys->totpart;
+ int amount = eff->psys->part->effector_amount;
+
+ *step = (totpart > amount) ? totpart/amount : 1;
+ }
}
else {
*p = 0;
@@ -770,7 +781,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
if(!eff->pd->tex)
return;
- result[0].nor = result[1].nor = result[2].nor = result[3].nor = 0;
+ result[0].nor = result[1].nor = result[2].nor = result[3].nor = NULL;
strength= eff->pd->f_strength * efd->falloff;
@@ -834,7 +845,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP
add_v3_v3(total_force, force);
}
-void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
+static void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
{
PartDeflect *pd = eff->pd;
RNG *rng = pd->rng;
@@ -990,7 +1001,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
*/
EffectorCache *eff;
EffectorData efd;
- int p=0, tot = 1;
+ int p=0, tot = 1, step = 1;
/* Cycle through collected objects, get total of (1/(gravity_strength * dist^gravity_power)) */
/* Check for min distance here? (yes would be cool to add that, ton) */
@@ -998,9 +1009,9 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we
if(effectors) for(eff = effectors->first; eff; eff=eff->next) {
/* object effectors were fully checked to be OK to evaluate! */
- get_effector_tot(eff, &efd, point, &tot, &p);
+ get_effector_tot(eff, &efd, point, &tot, &p, &step);
- for(; p<tot; p++) {
+ for(; p<tot; p+=step) {
if(get_effector_data(eff, &efd, point, 0)) {
efd.falloff= effector_falloff(eff, &efd, point, weights);
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index 641313b564c..e7596001400 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -364,10 +364,16 @@ static void read_stl_mesh_ascii(Scene *scene, const char *str)
* sure we have enough storage for some more faces
*/
if ( (totface) && ( (totface % 10000) == 0 ) ) {
+ float *vertdata_old= vertdata;
++numtenthousand;
vertdata = realloc(vertdata,
numtenthousand*3*30000*sizeof(float));
- if (!vertdata) { STLALLOCERROR; }
+ if (!vertdata) {
+ if(vertdata_old) {
+ free(vertdata_old);
+ }
+ STLALLOCERROR;
+ }
}
/* Don't read normal, but check line for proper syntax anyway
@@ -507,9 +513,6 @@ int BKE_read_exotic(Scene *scene, const char *name)
/* ************************ WRITE ************************** */
-
-char temp_dir[160]= {0, 0};
-
static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL)
{
float vert[3];
@@ -582,7 +585,6 @@ void write_stl(Scene *scene, char *str)
BKE_reportf(reports, RPT_ERROR, "Can't open file: %s.", strerror(errno));
return;
}
- strcpy(temp_dir, str);
//XXX waitcursor(1);
@@ -868,7 +870,6 @@ void write_dxf(struct Scene *scene, char *str)
//XXX error("Can't write file");
return;
}
- strcpy(temp_dir, str);
//XXX waitcursor(1);
@@ -1128,7 +1129,7 @@ static void dxf_add_mat (Object *ob, Mesh *me, float color[3], char *layer)
ma= G.main->mat.first;
while(ma) {
- if(ma->mtex[0]==0) {
+ if(ma->mtex[0]==NULL) {
if(color[0]==ma->r && color[1]==ma->g && color[2]==ma->b) {
me->mat[0]= ma;
ma->id.us++;
@@ -1137,7 +1138,7 @@ static void dxf_add_mat (Object *ob, Mesh *me, float color[3], char *layer)
}
ma= ma->id.next;
}
- if(ma==0) {
+ if(ma==NULL) {
ma= add_material("ext");
me->mat[0]= ma;
ma->r= color[0];
@@ -1646,7 +1647,7 @@ static void dxf_read_arc(Scene *scene, int noob)
cent[2]= center[2];
dxf_get_mesh(scene, &me, &ob, noob);
- strcpy(oldllay, layname);
+ BLI_strncpy(oldllay, layname, sizeof(oldllay));
if(ob) VECCOPY(ob->loc, cent);
dxf_add_mat (ob, me, color, layname);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index ef1ac582c1e..fc5aecb5def 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1202,7 +1202,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar)
/* ......... */
/* Table of Driver Varaiable Type Info Data */
-DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
+static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP)
dvar_eval_singleProp, /* eval callback */
1, /* number of targets used */
@@ -1233,7 +1233,7 @@ DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = {
};
/* Get driver variable typeinfo */
-DriverVarTypeInfo *get_dvar_typeinfo (int type)
+static DriverVarTypeInfo *get_dvar_typeinfo (int type)
{
/* check if valid type */
if ((type >= 0) && (type < MAX_DVAR_TYPES))
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 1d7ce197cba..bf0427e4fee 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -96,13 +96,14 @@ chtoutf8(unsigned long c, char *o)
void
wcs2utf8s(char *dst, wchar_t *src)
{
- char ch[5];
+ /* NULL terminator not needed */
+ char ch[4];
while(*src)
{
- memset(ch, 0, 5);
+ memset(ch, 0, sizeof(ch));
chtoutf8(*src++, ch);
- strcat(dst, ch);
+ dst= strncat(dst, ch, sizeof(ch));
}
}
@@ -207,7 +208,7 @@ int utf8towchar(wchar_t *w, char *c)
/* The vfont code */
void free_vfont(struct VFont *vf)
{
- if (vf == 0) return;
+ if (vf == NULL) return;
if (vf->data) {
while(vf->data->characters.first)
@@ -363,14 +364,14 @@ VFont *load_vfont(const char *name)
struct TmpFont *tmpfnt;
if (strcmp(name, FO_BUILTIN_NAME)==0) {
- strcpy(filename, name);
+ BLI_strncpy(filename, name, sizeof(filename));
pf= get_builtin_packedfile();
is_builtin= 1;
} else {
char dir[FILE_MAXDIR];
- strcpy(dir, name);
+ BLI_strncpy(dir, name, sizeof(dir));
BLI_splitdirstring(dir, filename);
pf= newPackedFile(NULL, name);
@@ -475,7 +476,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
nu2->flagu = CU_NURB_CYCLIC;
bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp");
- if (bp == 0){
+ if (bp == NULL){
MEM_freeN(nu2);
return;
}
@@ -543,10 +544,10 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
bezt1 = nu1->bezt;
if (bezt1){
nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb");
- if (nu2 == 0) break;
+ if (nu2 == NULL) break;
memcpy(nu2, nu1, sizeof(struct Nurb));
nu2->resolu= cu->resolu;
- nu2->bp = 0;
+ nu2->bp = NULL;
nu2->knotsu = nu2->knotsv = NULL;
nu2->flag= CU_SMOOTH;
nu2->charidx = charidx;
@@ -561,7 +562,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
i = nu2->pntsu;
bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple),"duplichar_bezt2");
- if (bezt2 == 0){
+ if (bezt2 == NULL){
MEM_freeN(nu2);
break;
}
@@ -685,14 +686,14 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
/* renark: do calculations including the trailing '\0' of a string
because the cursor can be at that location */
- if(ob->type!=OB_FONT) return 0;
+ if(ob->type!=OB_FONT) return NULL;
// Set font data
cu= (Curve *) ob->data;
vfont= cu->vfont;
- if(cu->str == NULL) return 0;
- if(vfont == NULL) return 0;
+ if(cu->str == NULL) return NULL;
+ if(vfont == NULL) return NULL;
// Create unicode string
utf8len = utf8slen(cu->str);
@@ -722,7 +723,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
if(!vfd) {
if(mem)
MEM_freeN(mem);
- return 0;
+ return NULL;
}
/* calc offset and rotation of each char */
@@ -786,11 +787,11 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
che= find_vfont_char(vfd, ascii);
/* No VFont found */
- if (vfont==0) {
+ if (vfont==NULL) {
if(mem)
MEM_freeN(mem);
MEM_freeN(chartransdata);
- return 0;
+ return NULL;
}
if (vfont != oldvfont) {
@@ -803,7 +804,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
if(mem)
MEM_freeN(mem);
MEM_freeN(chartransdata);
- return 0;
+ return NULL;
}
twidth = char_width(cu, che, info);
@@ -1218,7 +1219,5 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
MEM_freeN(mem);
MEM_freeN(chartransdata);
- return 0;
+ return NULL;
}
-
-
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 1df272fad30..b575305171a 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -106,14 +106,14 @@ void BKE_icons_init(int first_dyn_id)
gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh");
}
-void BKE_icons_free()
+void BKE_icons_free(void)
{
if(gIcons)
- BLI_ghash_free(gIcons, 0, icon_free);
+ BLI_ghash_free(gIcons, NULL, icon_free);
gIcons = NULL;
}
-struct PreviewImage* BKE_previewimg_create()
+struct PreviewImage* BKE_previewimg_create(void)
{
PreviewImage* prv_img = NULL;
int i;
@@ -219,7 +219,7 @@ PreviewImage* BKE_previewimg_get(ID *id)
void BKE_icon_changed(int id)
{
- Icon* icon = 0;
+ Icon* icon = NULL;
if (!id || G.background) return;
@@ -242,7 +242,7 @@ void BKE_icon_changed(int id)
int BKE_icon_getid(struct ID* id)
{
- Icon* new_icon = 0;
+ Icon* new_icon = NULL;
if (!id || G.background)
return 0;
@@ -263,8 +263,8 @@ int BKE_icon_getid(struct ID* id)
new_icon->type = GS(id->name);
/* next two lines make sure image gets created */
- new_icon->drawinfo = 0;
- new_icon->drawinfo_free = 0;
+ new_icon->drawinfo = NULL;
+ new_icon->drawinfo_free = NULL;
BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(id->icon_id), new_icon);
@@ -273,13 +273,13 @@ int BKE_icon_getid(struct ID* id)
Icon* BKE_icon_get(int icon_id)
{
- Icon* icon = 0;
+ Icon* icon = NULL;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
if (!icon) {
printf("BKE_icon_get: Internal error, no icon for icon ID: %d\n", icon_id);
- return 0;
+ return NULL;
}
return icon;
@@ -287,7 +287,7 @@ Icon* BKE_icon_get(int icon_id)
void BKE_icon_set(int icon_id, struct Icon* icon)
{
- Icon* old_icon = 0;
+ Icon* old_icon = NULL;
old_icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
@@ -305,6 +305,6 @@ void BKE_icon_delete(struct ID* id)
if (!id->icon_id) return; /* no icon defined for library object */
- BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), 0, icon_free);
+ BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), NULL, icon_free);
id->icon_id = 0;
}
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 0745fd5bdfd..e4086827e5d 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -33,6 +33,8 @@
#include "DNA_ID.h"
+#include "BKE_idcode.h"
+
typedef struct {
unsigned short code;
const char *name, *plural;
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 633d3aeafb9..97fbcce1aec 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -266,7 +266,7 @@ void IDP_FreeArray(IDProperty *prop)
return newp;
}
-IDProperty *IDP_CopyArray(IDProperty *prop)
+static IDProperty *IDP_CopyArray(IDProperty *prop)
{
IDProperty *newp = idp_generic_copy(prop);
@@ -328,7 +328,7 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen)
return prop;
}
-IDProperty *IDP_CopyString(IDProperty *prop)
+static IDProperty *IDP_CopyString(IDProperty *prop)
{
IDProperty *newp = idp_generic_copy(prop);
@@ -402,7 +402,7 @@ void IDP_UnlinkID(IDProperty *prop)
/*-------- Group Functions -------*/
/*checks if a property with the same name as prop exists, and if so replaces it.*/
-IDProperty *IDP_CopyGroup(IDProperty *prop)
+static IDProperty *IDP_CopyGroup(IDProperty *prop)
{
IDProperty *newp = idp_generic_copy(prop), *link;
newp->len = prop->len;
@@ -535,6 +535,12 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name)
return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name));
}
+IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type)
+{
+ IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name);
+ return (idprop && idprop->type == type) ? idprop : NULL;
+}
+
typedef struct IDPIter {
void *next;
IDProperty *parent;
@@ -705,9 +711,9 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name)
prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/
} else {
int stlen = strlen(st) + 1;
- prop->data.pointer = MEM_callocN(stlen, "id property string 2");
+ prop->data.pointer = MEM_mallocN(stlen, "id property string 2");
prop->len = prop->totallen = stlen;
- strcpy(prop->data.pointer, st);
+ memcpy(prop->data.pointer, st, stlen);
}
break;
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 3d69f51851f..64327b2005d 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -100,7 +100,7 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */
{
struct ImBuf * tbuf1, * tbuf2;
- if (ibuf == 0) return;
+ if (ibuf == NULL) return;
if (ibuf->flags & IB_fields) return;
ibuf->flags |= IB_fields;
@@ -128,7 +128,7 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */
{
struct ImBuf * tbuf1, * tbuf2;
- if (ibuf == 0) return;
+ if (ibuf == NULL) return;
if (ibuf->flags & IB_fields) return;
ibuf->flags |= IB_fields;
@@ -514,7 +514,7 @@ static void tag_all_images_time()
}
#endif
-void free_old_images()
+void free_old_images(void)
{
Image *ima;
static int lasttime = 0;
@@ -873,32 +873,23 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
time_t t;
if (scene->r.stamp & R_STAMP_FILENAME) {
- if (G.relbase_valid) {
- if (do_prefix) sprintf(stamp_data->file, "File %s", G.main->name);
- else sprintf(stamp_data->file, "%s", G.main->name);
- } else {
- if (do_prefix) strcpy(stamp_data->file, "File <untitled>");
- else strcpy(stamp_data->file, "<untitled>");
- }
+ BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s":"%s", G.relbase_valid ? G.main->name:"<untitled>");
} else {
stamp_data->file[0] = '\0';
}
if (scene->r.stamp & R_STAMP_NOTE) {
/* Never do prefix for Note */
- sprintf(stamp_data->note, "%s", scene->r.stamp_udata);
+ BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata);
} else {
stamp_data->note[0] = '\0';
}
if (scene->r.stamp & R_STAMP_DATE) {
-
- t = time (NULL);
- tl = localtime (&t);
- sprintf (text, "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec);
-
- if (do_prefix) sprintf(stamp_data->date, "Date %s", text);
- else sprintf(stamp_data->date, "%s", text);
+ t = time(NULL);
+ tl = localtime(&t);
+ BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec);
+ BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s":"%s", text);
} else {
stamp_data->date[0] = '\0';
}
@@ -908,9 +899,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (name) strcpy(text, name);
else strcpy(text, "<none>");
-
- if (do_prefix) sprintf(stamp_data->marker, "Marker %s", text);
- else sprintf(stamp_data->marker, "%s", text);
+
+ BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text);
} else {
stamp_data->marker[0] = '\0';
}
@@ -932,12 +922,11 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
}
if (scene->r.frs_sec < 100)
- sprintf (text, "%02d:%02d:%02d.%02d", h, m, s, f);
+ BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%02d", h, m, s, f);
else
- sprintf (text, "%02d:%02d:%02d.%03d", h, m, s, f);
-
- if (do_prefix) sprintf(stamp_data->time, "Time %s", text);
- else sprintf(stamp_data->time, "%s", text);
+ BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f);
+
+ BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s":"%s", text);
} else {
stamp_data->time[0] = '\0';
}
@@ -948,39 +937,32 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if(scene->r.efra>9)
digits= 1 + (int) log10(scene->r.efra);
-
- if (do_prefix) sprintf(format, "Frame %%0%di", digits);
- else sprintf(format, "%%0%di", digits);
- sprintf (stamp_data->frame, format, scene->r.cfra);
+
+ BLI_snprintf(format, sizeof(format), do_prefix ? "Frame %%0%di":"%%0%di", digits);
+ BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), format, scene->r.cfra);
} else {
stamp_data->frame[0] = '\0';
}
if (scene->r.stamp & R_STAMP_CAMERA) {
- if (scene->camera) strcpy(text, scene->camera->id.name+2);
- else strcpy(text, "<none>");
-
- if (do_prefix) sprintf(stamp_data->camera, "Camera %s", text);
- else sprintf(stamp_data->camera, "%s", text);
+ BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", scene->camera ? scene->camera->id.name+2 : "<none>");
} else {
stamp_data->camera[0] = '\0';
}
if (scene->r.stamp & R_STAMP_CAMERALENS) {
if (scene->camera && scene->camera->type == OB_CAMERA) {
- sprintf(text, "%.2f", ((Camera *)scene->camera->data)->lens);
+ BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)scene->camera->data)->lens);
}
else strcpy(text, "<none>");
- if (do_prefix) sprintf(stamp_data->cameralens, "Lens %s", text);
- else sprintf(stamp_data->cameralens, "%s", text);
+ BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text);
} else {
stamp_data->cameralens[0] = '\0';
}
if (scene->r.stamp & R_STAMP_SCENE) {
- if (do_prefix) sprintf(stamp_data->scene, "Scene %s", scene->id.name+2);
- else sprintf(stamp_data->scene, "%s", scene->id.name+2);
+ BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s":"%s", scene->id.name+2);
} else {
stamp_data->scene[0] = '\0';
}
@@ -990,9 +972,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (seq) strcpy(text, seq->name+2);
else strcpy(text, "<none>");
-
- if (do_prefix) sprintf(stamp_data->strip, "Strip %s", text);
- else sprintf(stamp_data->strip, "%s", text);
+
+ BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text);
} else {
stamp_data->strip[0] = '\0';
}
@@ -1004,8 +985,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
BLI_timestr(stats->lastframetime, text);
- if (do_prefix) sprintf(stamp_data->rendertime, "RenderTime %s", text);
- else sprintf(stamp_data->rendertime, "%s", text);
+ BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s":"%s", text);
} else {
stamp_data->rendertime[0] = '\0';
}
@@ -1262,7 +1242,7 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int
ibuf->ftype= IMAGIC;
}
#ifdef WITH_HDR
- else if ((imtype==R_RADHDR)) {
+ else if (imtype==R_RADHDR) {
ibuf->ftype= RADHDR;
}
#endif
@@ -1274,11 +1254,11 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int
}
#ifdef WITH_DDS
- else if ((imtype==R_DDS)) {
+ else if (imtype==R_DDS) {
ibuf->ftype= DDS;
}
#endif
- else if ((imtype==R_BMP)) {
+ else if (imtype==R_BMP) {
ibuf->ftype= BMP;
}
#ifdef WITH_TIFF
@@ -1379,7 +1359,7 @@ struct anim *openanim(char *name, int flags)
struct ImBuf *ibuf;
anim = IMB_open_anim(name, flags);
- if (anim == NULL) return(0);
+ if (anim == NULL) return NULL;
ibuf = IMB_anim_absolute(anim, 0);
if (ibuf == NULL) {
@@ -1388,7 +1368,7 @@ struct anim *openanim(char *name, int flags)
else
printf("anim file doesn't exist: %s\n", name);
IMB_free_anim(anim);
- return(0);
+ return NULL;
}
IMB_freeImBuf(ibuf);
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index a2d41920217..c21e347d6d8 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -25,6 +25,8 @@
#include <math.h>
#include <stdlib.h>
+
+#include "BKE_image.h"
#include "BLI_math_color.h"
#include "BLF_api.h"
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index db995fd4f1d..329058b3115 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -62,7 +62,7 @@
#include "BLI_utildefines.h"
-
+#include "BKE_ipo.h"
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_fcurve.h"
@@ -709,6 +709,11 @@ static const char *world_adrcodes_to_paths (int adrcode, int *array_index)
*array_index= 1; return "stars.color";
case WO_STAR_B:
*array_index= 2; return "stars.color"; */
+ case WO_STAR_R:
+ case WO_STAR_G:
+ case WO_STAR_B:
+ printf("WARNING: WO_STAR_R/G/B deprecated\n");
+ return NULL;
case WO_STARDIST:
return "stars.min_distance";
@@ -798,7 +803,7 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index)
* - array_index - index in property's array (if applicable) to use
* - return - the allocated path...
*/
-static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence * seq, int *array_index)
+static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index)
{
DynStr *path= BLI_dynstr_new();
const char *propname=NULL;
@@ -914,8 +919,17 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname);
}
else if (actname && actname[0]) {
- /* Pose-Channel */
- sprintf(buf, "pose.bones[\"%s\"]", actname);
+ if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) {
+ /* Actionified "Object" IPO's... no extra path stuff needed */
+ }
+ else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) {
+ /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */
+ strcpy(buf, "data.shape_keys");
+ }
+ else {
+ /* Pose-Channel */
+ sprintf(buf, "pose.bones[\"%s\"]", actname);
+ }
}
else if (constname && constname[0]) {
/* Constraint in Object */
@@ -923,8 +937,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
}
else if (seq) {
/* Sequence names in Scene */
- sprintf(buf, "sequence_editor.sequences_all[\"%s\"]",
- seq->name+2);
+ sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2);
}
else
strcpy(buf, ""); /* empty string */
@@ -1321,20 +1334,17 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *
}
}
- /* correct values for sequencer curves,
- that were not locked to frame */
-
- if (seq &&
- (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
+ /* correct values for sequencer curves, that were not locked to frame */
+ if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
double mul= (seq->enddisp-seq->startdisp)/100.0f;
double offset= seq->startdisp;
dst->vec[0][0] *= mul;
dst->vec[0][0] += offset;
-
+
dst->vec[1][0] *= mul;
dst->vec[1][0] += offset;
-
+
dst->vec[2][0] *= mul;
dst->vec[2][0] += offset;
}
@@ -1481,7 +1491,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase
* This assumes that AnimData has been added already. Separation of drivers
* from animation data is accomplished here too...
*/
-static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq)
+static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq)
{
AnimData *adt= BKE_animdata_from_id(id);
ListBase anim = {NULL, NULL};
@@ -1512,8 +1522,12 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[],
if (G.f & G_DEBUG) printf("\thas anim \n");
/* try to get action */
if (adt->action == NULL) {
- adt->action= add_empty_action("ConvData_Action"); // XXX we need a better name for this
- if (G.f & G_DEBUG) printf("\t\tadded new action \n");
+ char nameBuf[MAX_ID_NAME];
+
+ BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name+2);
+
+ adt->action= add_empty_action(nameBuf);
+ if (G.f & G_DEBUG) printf("\t\tadded new action - '%s' \n", nameBuf);
}
/* add F-Curves to action */
@@ -1869,7 +1883,7 @@ void do_versions_ipos_to_animato(Main *main)
to different DNA variables later
(semi-hack (tm) )
*/
- switch(seq->type) {
+ switch (seq->type) {
case SEQ_IMAGE:
case SEQ_META:
case SEQ_SCENE:
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index a3c8ea0c194..3681dc910cd 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -150,7 +150,7 @@ Key *copy_key(Key *key)
Key *keyn;
KeyBlock *kbn, *kb;
- if(key==0) return 0;
+ if(key==NULL) return NULL;
keyn= copy_libblock(key);
@@ -177,10 +177,10 @@ void make_local_key(Key *key)
* - only local users: set flag
* - mixed: make copy
*/
- if(key==0) return;
+ if(key==NULL) return;
- key->id.lib= 0;
- new_id(0, (ID *)key, 0);
+ key->id.lib= NULL;
+ new_id(NULL, (ID *)key, NULL);
}
/* Sort shape keys and Ipo curves after a change. This assumes that at most
@@ -365,14 +365,14 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
/* if(fac<0.0 || fac>1.0) return 1; */
- if(k1->next==0) return 1;
+ if(k1->next==NULL) return 1;
if(cycl) { /* pre-sort */
k[2]= k1->next;
k[3]= k[2]->next;
- if(k[3]==0) k[3]=k1;
+ if(k[3]==NULL) k[3]=k1;
while(k1) {
- if(k1->next==0) k[0]=k1;
+ if(k1->next==NULL) k[0]=k1;
k1=k1->next;
}
k1= k[1];
@@ -393,13 +393,13 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl)
k[2]= k1->next;
t[2]= k[2]->pos;
k[3]= k[2]->next;
- if(k[3]==0) k[3]= k[2];
+ if(k[3]==NULL) k[3]= k[2];
t[3]= k[3]->pos;
k1= k[3];
}
while( t[2]<fac ) { /* find correct location */
- if(k1->next==0) {
+ if(k1->next==NULL) {
if(cycl) {
k1= firstkey;
ofs+= dpos;
@@ -1081,7 +1081,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int
for(a=0; a<tot; a+=step, cfra+= delta) {
- ctime= bsystem_time(scene, 0, cfra, 0.0); // xxx ugly cruft!
+ ctime= bsystem_time(scene, NULL, cfra, 0.0); // xxx ugly cruft!
#if 0 // XXX old animation system
if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
@@ -1213,7 +1213,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in
while (a < estep) {
if (remain <= 0) {
cfra+= delta;
- ctime= bsystem_time(scene, 0, cfra, 0.0f); // XXX old cruft
+ ctime= bsystem_time(scene, NULL, cfra, 0.0f); // XXX old cruft
ctime /= 100.0f;
CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing
@@ -1276,7 +1276,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int
for(a=0; a<tot; a++, cfra+= delta) {
- ctime= bsystem_time(scene, 0, cfra, 0.0); // XXX old cruft
+ ctime= bsystem_time(scene, NULL, cfra, 0.0); // XXX old cruft
#if 0 // XXX old animation system
if(calc_ipo_spec(key->ipo, KEY_SPEED, &ctime)==0) {
ctime /= 100.0;
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index be3ec62374f..bd7fdfebe97 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -251,11 +251,11 @@ void make_local_lattice(Lattice *lt)
* - mixed: make copy
*/
- if(lt->id.lib==0) return;
+ if(lt->id.lib==NULL) return;
if(lt->id.us==1) {
- lt->id.lib= 0;
+ lt->id.lib= NULL;
lt->id.flag= LIB_LOCAL;
- new_id(0, (ID *)lt, 0);
+ new_id(NULL, (ID *)lt, NULL);
return;
}
@@ -269,9 +269,9 @@ void make_local_lattice(Lattice *lt)
}
if(local && lib==0) {
- lt->id.lib= 0;
+ lt->id.lib= NULL;
lt->id.flag= LIB_LOCAL;
- new_id(0, (ID *)lt, 0);
+ new_id(NULL, (ID *)lt, NULL);
}
else if(local && lib) {
ltn= copy_lattice(lt);
@@ -281,7 +281,7 @@ void make_local_lattice(Lattice *lt)
while(ob) {
if(ob->data==lt) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= ltn;
ltn->id.us++;
lt->id.us--;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 58167a866a3..28410a7cc0e 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -313,7 +313,7 @@ int id_copy(ID *id, ID **newid, int test)
if(!test) *newid= (ID*)copy_action((bAction*)id);
return 1;
case ID_NT:
- if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id, 0);
+ if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id);
return 1;
case ID_BR:
if(!test) *newid= (ID*)copy_brush((Brush*)id);
@@ -426,7 +426,7 @@ ListBase *which_libbase(Main *mainlib, short type)
case ID_LS:
return &(mainlib->linestyle);
}
- return 0;
+ return NULL;
}
/* Flag all ids in listbase */
@@ -699,7 +699,7 @@ void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) )
free_windowmanager_cb= func;
}
-void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata)
+static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata)
{
ChannelDriver *driver;
FCurve *fcu;
@@ -934,7 +934,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
BLI_dynstr_append(pupds, buf);
BLI_dynstr_append(pupds, id->name+2);
- sprintf(buf, "%%x%d", i+1);
+ BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1);
BLI_dynstr_append(pupds, buf);
/* icon */
@@ -945,7 +945,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
case ID_IM: /* fall through */
case ID_WO: /* fall through */
case ID_LA: /* fall through */
- sprintf(buf, "%%i%d", BKE_icon_getid(id) );
+ BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) );
BLI_dynstr_append(pupds, buf);
break;
default:
@@ -1021,7 +1021,7 @@ static void sort_alpha_id(ListBase *lb, ID *id)
idtest= idtest->next;
}
/* as last */
- if(idtest==0) {
+ if(idtest==NULL) {
BLI_addtail(lb, id);
}
}
@@ -1142,7 +1142,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
continue;
}
/* this format specifier is from hell... */
- sprintf(name, "%s.%.3d", left, nr);
+ BLI_snprintf(name, sizeof(id->name) - 2,"%s.%.3d", left, nr);
return 1;
}
@@ -1203,7 +1203,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
}
/* next to indirect usage in read/writefile also in editobject.c scene.c */
-void clear_id_newpoins()
+void clear_id_newpoins(void)
{
ListBase *lbarray[MAX_LIBARRAY];
ID *id;
@@ -1213,7 +1213,7 @@ void clear_id_newpoins()
while(a--) {
id= lbarray[a]->first;
while(id) {
- id->newid= 0;
+ id->newid= NULL;
id->flag &= ~LIB_NEW;
id= id->next;
}
@@ -1307,7 +1307,7 @@ void tag_main(struct Main *mainvar, const short tag)
/* if lib!=NULL, only all from lib local */
void all_local(Library *lib, int untagged_only)
{
- ListBase *lbarray[MAX_LIBARRAY], tempbase={0, 0};
+ ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL};
ID *id, *idn;
int a;
@@ -1336,7 +1336,7 @@ void all_local(Library *lib, int untagged_only)
image_fix_relative_path((Image *)id);
id->lib= NULL;
- new_id(lbarray[a], id, 0); /* new_id only does it with double names */
+ new_id(lbarray[a], id, NULL); /* new_id only does it with double names */
sort_alpha_id(lbarray[a], id);
}
}
@@ -1348,7 +1348,7 @@ void all_local(Library *lib, int untagged_only)
while( (id=tempbase.first) ) {
BLI_remlink(&tempbase, id);
BLI_addtail(lbarray[a], id);
- new_id(lbarray[a], id, 0);
+ new_id(lbarray[a], id, NULL);
}
}
@@ -1369,7 +1369,7 @@ void test_idbutton(char *name)
lb= which_libbase(G.main, GS(name-2) );
- if(lb==0) return;
+ if(lb==NULL) return;
/* search for id */
idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 5ee41246bf9..cd52a38140a 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -224,7 +224,7 @@ Material *copy_material(Material *ma)
if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
if(ma->nodetree) {
- man->nodetree= ntreeCopyTree(ma->nodetree, 0); /* 0 == full new tree */
+ man->nodetree= ntreeCopyTree(ma->nodetree); /* 0 == full new tree */
}
man->gpumaterial.first= man->gpumaterial.last= NULL;
@@ -279,11 +279,11 @@ void make_local_material(Material *ma)
* - mixed: make copy
*/
- if(ma->id.lib==0) return;
+ if(ma->id.lib==NULL) return;
if(ma->id.us==1) {
- ma->id.lib= 0;
+ ma->id.lib= NULL;
ma->id.flag= LIB_LOCAL;
- new_id(0, (ID *)ma, 0);
+ new_id(NULL, (ID *)ma, NULL);
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
}
@@ -345,14 +345,14 @@ void make_local_material(Material *ma)
}
if(local && lib==0) {
- ma->id.lib= 0;
+ ma->id.lib= NULL;
ma->id.flag= LIB_LOCAL;
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex);
}
- new_id(0, (ID *)ma, 0);
+ new_id(NULL, (ID *)ma, NULL);
}
else if(local && lib) {
@@ -365,7 +365,7 @@ void make_local_material(Material *ma)
if(ob->mat) {
for(a=0; a<ob->totcol; a++) {
if(ob->mat[a]==ma) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->mat[a]= man;
man->id.us++;
ma->id.us--;
@@ -381,7 +381,7 @@ void make_local_material(Material *ma)
if(me->mat) {
for(a=0; a<me->totcol; a++) {
if(me->mat[a]==ma) {
- if(me->id.lib==0) {
+ if(me->id.lib==NULL) {
me->mat[a]= man;
man->id.us++;
ma->id.us--;
@@ -397,7 +397,7 @@ void make_local_material(Material *ma)
if(cu->mat) {
for(a=0; a<cu->totcol; a++) {
if(cu->mat[a]==ma) {
- if(cu->id.lib==0) {
+ if(cu->id.lib==NULL) {
cu->mat[a]= man;
man->id.us++;
ma->id.us--;
@@ -413,7 +413,7 @@ void make_local_material(Material *ma)
if(mb->mat) {
for(a=0; a<mb->totcol; a++) {
if(mb->mat[a]==ma) {
- if(mb->id.lib==0) {
+ if(mb->id.lib==NULL) {
mb->mat[a]= man;
man->id.us++;
ma->id.us--;
@@ -584,7 +584,7 @@ Material *give_current_material(Object *ob, int act)
matarar= give_matarar(ob);
if(matarar && *matarar) ma= (*matarar)[act-1];
- else ma= 0;
+ else ma= NULL;
}
@@ -594,7 +594,7 @@ Material *give_current_material(Object *ob, int act)
ID *material_from(Object *ob, int act)
{
- if(ob==0) return 0;
+ if(ob==NULL) return NULL;
if(ob->totcol==0) return ob->data;
if(act==0) act= 1;
@@ -689,7 +689,7 @@ void assign_material(Object *ob, Material *ma, int act)
totcolp= give_totcolp(ob);
matarar= give_matarar(ob);
- if(totcolp==0 || matarar==0) return;
+ if(totcolp==NULL || matarar==NULL) return;
if(act > *totcolp) {
matar= MEM_callocN(sizeof(void *)*act, "matarray1");
@@ -783,7 +783,7 @@ int object_add_material_slot(Object *ob)
{
Material *ma;
- if(ob==0) return FALSE;
+ if(ob==NULL) return FALSE;
if(ob->totcol>=MAXMAT) return FALSE;
ma= give_current_material(ob, ob->actcol);
@@ -965,7 +965,7 @@ int material_in_material(Material *parmat, Material *mat)
/* ****************** */
-char colname_array[125][20]= {
+static char colname_array[125][20]= {
"Black","DarkRed","HalfRed","Red","Red",
"DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed",
"HalfGreen","GreenOlive","DryOlive","Goldenrod","DarkOrange",
@@ -998,7 +998,7 @@ void automatname(Material *ma)
int nr, r, g, b;
float ref;
- if(ma==0) return;
+ if(ma==NULL) return;
if(ma->mode & MA_SHLESS) ref= 1.0;
else ref= ma->ref;
@@ -1046,7 +1046,7 @@ int object_remove_material_slot(Object *ob)
if(*totcolp==0) {
MEM_freeN(*matarar);
- *matarar= 0;
+ *matarar= NULL;
}
actcol= ob->actcol;
@@ -1069,7 +1069,7 @@ int object_remove_material_slot(Object *ob)
if(obt->totcol==0) {
MEM_freeN(obt->mat);
MEM_freeN(obt->matbits);
- obt->mat= 0;
+ obt->mat= NULL;
obt->matbits= NULL;
}
}
@@ -1350,7 +1350,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col)
/* copy/paste buffer, if we had a propper py api that would be better */
Material matcopybuf;
-static short matcopied=0;
+static short matcopied= 0;
void clear_matcopybuf(void)
{
@@ -1402,7 +1402,7 @@ void copy_matcopybuf(Material *ma)
matcopybuf.mtex[a]= MEM_dupallocN(mtex);
}
}
- matcopybuf.nodetree= ntreeCopyTree(ma->nodetree, 0);
+ matcopybuf.nodetree= ntreeCopyTree(ma->nodetree);
matcopybuf.preview= NULL;
matcopybuf.gpumaterial.first= matcopybuf.gpumaterial.last= NULL;
matcopied= 1;
@@ -1447,5 +1447,5 @@ void paste_matcopybuf(Material *ma)
}
}
- ma->nodetree= ntreeCopyTree(matcopybuf.nodetree, 0);
+ ma->nodetree= ntreeCopyTree(matcopybuf.nodetree);
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index a22fc165de7..d89bc3cd6f2 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -77,7 +77,7 @@ void unlink_mball(MetaBall *mb)
for(a=0; a<mb->totcol; a++) {
if(mb->mat[a]) mb->mat[a]->id.us--;
- mb->mat[a]= 0;
+ mb->mat[a]= NULL;
}
}
@@ -142,9 +142,9 @@ void make_local_mball(MetaBall *mb)
* - mixed: make copy
*/
- if(mb->id.lib==0) return;
+ if(mb->id.lib==NULL) return;
if(mb->id.us==1) {
- mb->id.lib= 0;
+ mb->id.lib= NULL;
mb->id.flag= LIB_LOCAL;
return;
}
@@ -159,7 +159,7 @@ void make_local_mball(MetaBall *mb)
}
if(local && lib==0) {
- mb->id.lib= 0;
+ mb->id.lib= NULL;
mb->id.flag= LIB_LOCAL;
}
else if(local && lib) {
@@ -170,7 +170,7 @@ void make_local_mball(MetaBall *mb)
while(ob) {
if(ob->data==mb) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= mbn;
mbn->id.us++;
mb->id.us--;
@@ -242,7 +242,7 @@ void tex_space_mball(Object *ob)
float *data, min[3], max[3], loc[3], size[3];
int tot, doit=0;
- if(ob->bb==0) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox");
+ if(ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox");
bb= ob->bb;
/* Weird one, this. */
@@ -372,7 +372,7 @@ void copy_mball_properties(Scene *scene, Object *active_object)
BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.');
/* XXX recursion check, see scene.c, just too simple code this next_object() */
- if(F_ERROR==next_object(&sce_iter, 0, 0, 0))
+ if(F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
return;
while(next_object(&sce_iter, 1, &base, &ob)) {
@@ -418,7 +418,7 @@ Object *find_basis_mball(Scene *scene, Object *basis)
totelem= 0;
/* XXX recursion check, see scene.c, just too simple code this next_object() */
- if(F_ERROR==next_object(&sce_iter, 0, 0, 0))
+ if(F_ERROR==next_object(&sce_iter, 0, NULL, NULL))
return NULL;
while(next_object(&sce_iter, 1, &base, &ob)) {
@@ -698,8 +698,8 @@ float metaball(float x, float y, float z)
/* ******************************************** */
-int *indices=NULL;
-int totindex, curindex;
+static int *indices=NULL;
+static int totindex, curindex;
void accum_mballfaces(int i1, int i2, int i3, int i4)
@@ -742,8 +742,8 @@ void *new_pgn_element(int size)
*/
int blocksize= 16384;
static int offs= 0; /* the current free address */
- static struct pgn_elements *cur= 0;
- static ListBase lb= {0, 0};
+ static struct pgn_elements *cur= NULL;
+ static ListBase lb= {NULL, NULL};
void *adr;
if(size>10000 || size==0) {
@@ -925,14 +925,14 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i
newc.corners[FLIP(c3, bit)] = corn3;
newc.corners[FLIP(c4, bit)] = corn4;
- if(newc.corners[0]==0) newc.corners[0] = setcorner(p, i, j, k);
- if(newc.corners[1]==0) newc.corners[1] = setcorner(p, i, j, k+1);
- if(newc.corners[2]==0) newc.corners[2] = setcorner(p, i, j+1, k);
- if(newc.corners[3]==0) newc.corners[3] = setcorner(p, i, j+1, k+1);
- if(newc.corners[4]==0) newc.corners[4] = setcorner(p, i+1, j, k);
- if(newc.corners[5]==0) newc.corners[5] = setcorner(p, i+1, j, k+1);
- if(newc.corners[6]==0) newc.corners[6] = setcorner(p, i+1, j+1, k);
- if(newc.corners[7]==0) newc.corners[7] = setcorner(p, i+1, j+1, k+1);
+ if(newc.corners[0]==NULL) newc.corners[0] = setcorner(p, i, j, k);
+ if(newc.corners[1]==NULL) newc.corners[1] = setcorner(p, i, j, k+1);
+ if(newc.corners[2]==NULL) newc.corners[2] = setcorner(p, i, j+1, k);
+ if(newc.corners[3]==NULL) newc.corners[3] = setcorner(p, i, j+1, k+1);
+ if(newc.corners[4]==NULL) newc.corners[4] = setcorner(p, i+1, j, k);
+ if(newc.corners[5]==NULL) newc.corners[5] = setcorner(p, i+1, j, k+1);
+ if(newc.corners[6]==NULL) newc.corners[6] = setcorner(p, i+1, j+1, k);
+ if(newc.corners[7]==NULL) newc.corners[7] = setcorner(p, i+1, j+1, k+1);
p->cubes->cube= newc;
}
@@ -1031,7 +1031,7 @@ void makecubetable (void)
for (c = 0; c < 8; c++) pos[c] = MB_BIT(i, c);
for (e = 0; e < 12; e++)
if (!done[e] && (pos[corner1[e]] != pos[corner2[e]])) {
- INTLIST *ints = 0;
+ INTLIST *ints = NULL;
INTLISTS *lists = (INTLISTS *) MEM_callocN(sizeof(INTLISTS), "mball_intlist");
int start = e, edge = e;
@@ -1080,7 +1080,7 @@ void BKE_freecubetable(void)
MEM_freeN(lists);
lists= nlists;
}
- cubetable[i]= 0;
+ cubetable[i]= NULL;
}
}
@@ -1594,7 +1594,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
BLI_split_name_num(obname, &obnr, ob->id.name+2, '.');
/* make main array */
- next_object(&sce_iter, 0, 0, 0);
+ next_object(&sce_iter, 0, NULL, NULL);
while(next_object(&sce_iter, 1, &base, &bob)) {
if(bob->type==OB_MBALL) {
@@ -2174,7 +2174,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
if(G.moving && mb->flag==MB_UPDATE_FAST) return;
curindex= totindex= 0;
- indices= 0;
+ indices= NULL;
thresh= mb->thresh;
/* total number of MetaElems (totelem) is precomputed in find_basis_mball() function */
@@ -2229,7 +2229,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
mbproc.function = metaball;
mbproc.size = width;
mbproc.bounds = nr_cubes;
- mbproc.cubes= 0;
+ mbproc.cubes= NULL;
mbproc.delta = width/(float)(RES*RES);
polygonize(&mbproc, mb);
@@ -2251,7 +2251,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase)
dl->parts= curindex;
dl->index= indices;
- indices= 0;
+ indices= NULL;
a= mbproc.vertices.count;
dl->verts= ve= MEM_mallocN(sizeof(float)*3*a, "mballverts");
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index dc4838366c4..3c56cb4663b 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -98,11 +98,11 @@ void unlink_mesh(Mesh *me)
{
int a;
- if(me==0) return;
+ if(me==NULL) return;
for(a=0; a<me->totcol; a++) {
if(me->mat[a]) me->mat[a]->id.us--;
- me->mat[a]= 0;
+ me->mat[a]= NULL;
}
if(me->key) {
@@ -110,9 +110,9 @@ void unlink_mesh(Mesh *me)
if (me->key->id.us == 0 && me->key->ipo )
me->key->ipo->id.us--;
}
- me->key= 0;
+ me->key= NULL;
- if(me->texcomesh) me->texcomesh= 0;
+ if(me->texcomesh) me->texcomesh= NULL;
}
@@ -255,9 +255,9 @@ void make_local_tface(Mesh *me)
if(tface->tpage) {
ima= tface->tpage;
if(ima->id.lib) {
- ima->id.lib= 0;
+ ima->id.lib= NULL;
ima->id.flag= LIB_LOCAL;
- new_id(0, (ID *)ima, 0);
+ new_id(NULL, (ID *)ima, NULL);
}
}
}
@@ -277,11 +277,11 @@ void make_local_mesh(Mesh *me)
* - mixed: make copy
*/
- if(me->id.lib==0) return;
+ if(me->id.lib==NULL) return;
if(me->id.us==1) {
- me->id.lib= 0;
+ me->id.lib= NULL;
me->id.flag= LIB_LOCAL;
- new_id(0, (ID *)me, 0);
+ new_id(NULL, (ID *)me, NULL);
if(me->mtface) make_local_tface(me);
@@ -298,9 +298,9 @@ void make_local_mesh(Mesh *me)
}
if(local && lib==0) {
- me->id.lib= 0;
+ me->id.lib= NULL;
me->id.flag= LIB_LOCAL;
- new_id(0, (ID *)me, 0);
+ new_id(NULL, (ID *)me, NULL);
if(me->mtface) make_local_tface(me);
@@ -312,7 +312,7 @@ void make_local_mesh(Mesh *me)
ob= bmain->object.first;
while(ob) {
if( me==get_mesh(ob) ) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
set_mesh(ob, men);
}
}
@@ -327,7 +327,7 @@ void boundbox_mesh(Mesh *me, float *loc, float *size)
float min[3], max[3];
float mloc[3], msize[3];
- if(me->bb==0) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
+ if(me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox");
bb= me->bb;
if (!loc) loc= mloc;
@@ -444,7 +444,7 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
mface->v4= 0;
nr--;
}
- if(mface->v2 && mface->v2==mface->v3) {
+ if((mface->v2 || mface->v4) && mface->v2==mface->v3) {
mface->v3= mface->v4;
mface->v4= 0;
nr--;
@@ -456,6 +456,32 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
nr--;
}
+ /* check corrupt cases, bowtie geometry, cant handle these because edge data wont exist so just return 0 */
+ if(nr==3) {
+ if(
+ /* real edges */
+ mface->v1==mface->v2 ||
+ mface->v2==mface->v3 ||
+ mface->v3==mface->v1
+ ) {
+ return 0;
+ }
+ }
+ else if(nr==4) {
+ if(
+ /* real edges */
+ mface->v1==mface->v2 ||
+ mface->v2==mface->v3 ||
+ mface->v3==mface->v4 ||
+ mface->v4==mface->v1 ||
+ /* across the face */
+ mface->v1==mface->v3 ||
+ mface->v2==mface->v4
+ ) {
+ return 0;
+ }
+ }
+
/* prevent a zero at wrong index location */
if(nr==3) {
if(mface->v3==0) {
@@ -486,18 +512,18 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
Mesh *get_mesh(Object *ob)
{
- if(ob==0) return 0;
+ if(ob==NULL) return NULL;
if(ob->type==OB_MESH) return ob->data;
- else return 0;
+ else return NULL;
}
void set_mesh(Object *ob, Mesh *me)
{
- Mesh *old=0;
+ Mesh *old=NULL;
multires_force_update(ob);
- if(ob==0) return;
+ if(ob==NULL) return;
if(ob->type==OB_MESH) {
old= ob->data;
@@ -678,6 +704,23 @@ void mesh_strip_loose_faces(Mesh *me)
me->totface = b;
}
+void mesh_strip_loose_edges(Mesh *me)
+{
+ int a,b;
+
+ for (a=b=0; a<me->totedge; a++) {
+ if (me->medge[a].v1!=me->medge[a].v2) {
+ if (a!=b) {
+ memcpy(&me->medge[b],&me->medge[a],sizeof(me->medge[b]));
+ CustomData_copy_data(&me->edata, &me->edata, a, b, 1);
+ CustomData_free_elem(&me->edata, a, 1);
+ }
+ b++;
+ }
+ }
+ me->totedge = b;
+}
+
void mball_to_mesh(ListBase *lb, Mesh *me)
{
DispList *dl;
@@ -687,7 +730,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me)
int a, *index;
dl= lb->first;
- if(dl==0) return;
+ if(dl==NULL) return;
if(dl->type==DL_INDEX4) {
me->totvert= dl->nr;
@@ -789,7 +832,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int
}
*allvert= mvert= MEM_callocN(sizeof (MVert) * totvert, "nurbs_init mvert");
- *allface= mface= MEM_callocN(sizeof (MVert) * totvert, "nurbs_init mface");
+ *allface= mface= MEM_callocN(sizeof (MVert) * totvlak, "nurbs_init mface");
/* verts and faces */
vertcount= 0;
@@ -980,7 +1023,7 @@ void nurbs_to_mesh(Object *ob)
tex_space_mesh(me);
- cu->mat= 0;
+ cu->mat= NULL;
cu->totcol= 0;
if(ob->data) {
@@ -1513,7 +1556,10 @@ int mesh_center_median(Mesh *me, float cent[3])
for(mvert= me->mvert; i--; mvert++) {
add_v3_v3(cent, mvert->co);
}
- mul_v3_fl(cent, 1.0f/(float)me->totvert);
+ /* otherwise we get NAN for 0 verts */
+ if(me->totvert) {
+ mul_v3_fl(cent, 1.0f/(float)me->totvert);
+ }
return (me->totvert != 0);
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
new file mode 100644
index 00000000000..e5aacdf2cf9
--- /dev/null
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -0,0 +1,379 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * All rights reserved.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+
+#include "BLO_sys_types.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_edgehash.h"
+
+#include "BKE_DerivedMesh.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_mesh.h"
+
+#define SELECT 1
+
+typedef union {
+ uint32_t verts[2];
+ int64_t edval;
+} EdgeUUID;
+
+typedef struct SortFace {
+// unsigned int v[4];
+ EdgeUUID es[4];
+ unsigned int index;
+} SortFace;
+
+static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2)
+{
+ if(v1 < v2) {
+ verts[0]= v1;
+ verts[1]= v2;
+ }
+ else {
+ verts[0]= v2;
+ verts[1]= v1;
+ }
+}
+
+static void edge_store_from_mface_quad(EdgeUUID es[4], MFace *mf)
+{
+ edge_store_assign(es[0].verts, mf->v1, mf->v2);
+ edge_store_assign(es[1].verts, mf->v2, mf->v3);
+ edge_store_assign(es[2].verts, mf->v3, mf->v4);
+ edge_store_assign(es[3].verts, mf->v4, mf->v1);
+}
+
+static void edge_store_from_mface_tri(EdgeUUID es[3], MFace *mf)
+{
+ edge_store_assign(es[0].verts, mf->v1, mf->v2);
+ edge_store_assign(es[1].verts, mf->v2, mf->v3);
+ edge_store_assign(es[2].verts, mf->v3, mf->v1);
+ es[3].verts[0] = es[3].verts[1] = UINT_MAX;
+}
+
+static int int64_cmp(const void *v1, const void *v2)
+{
+ const int64_t x1= *(const int64_t *)v1;
+ const int64_t x2= *(const int64_t *)v2;
+
+ if( x1 > x2 ) return 1;
+ else if( x1 < x2 ) return -1;
+ return 0;
+}
+
+static int search_face_cmp(const void *v1, const void *v2)
+{
+ const SortFace *sfa= v1, *sfb= v2;
+
+ if (sfa->es[0].edval > sfb->es[0].edval) return 1;
+ else if (sfa->es[0].edval < sfb->es[0].edval) return -1;
+
+ else if (sfa->es[1].edval > sfb->es[1].edval) return 1;
+ else if (sfa->es[1].edval < sfb->es[1].edval) return -1;
+
+ else if (sfa->es[2].edval > sfb->es[2].edval) return 1;
+ else if (sfa->es[2].edval < sfb->es[2].edval) return -1;
+
+ else if (sfa->es[3].edval > sfb->es[3].edval) return 1;
+ else if (sfa->es[3].edval < sfb->es[3].edval) return -1;
+ else return 0;
+
+}
+
+int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface, const short do_verbose, const short do_fixes)
+{
+# define PRINT if(do_verbose) printf
+# define REMOVE_EDGE_TAG(_med) { _med->v2= _med->v1; do_edge_free= 1; }
+# define REMOVE_FACE_TAG(_mf) { _mf->v3=0; do_face_free= 1; }
+
+// MVert *mv;
+ MEdge *med;
+ MFace *mf;
+ MFace *mf_prev;
+ int i;
+
+ int do_face_free= FALSE;
+ int do_edge_free= FALSE;
+
+ int do_edge_recalc= FALSE;
+
+ EdgeHash *edge_hash = BLI_edgehash_new();
+
+ SortFace *sort_faces= MEM_callocN(sizeof(SortFace) * totface, "search faces");
+ SortFace *sf;
+ SortFace *sf_prev;
+ int totsortface= 0;
+
+ BLI_assert(!(do_fixes && me == NULL));
+
+ PRINT("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface);
+
+ if(totedge == 0 && totface != 0) {
+ PRINT(" locical error, %d faces and 0 edges\n", totface);
+ do_edge_recalc= TRUE;
+ }
+
+ for(i=0, med= medges; i<totedge; i++, med++) {
+ int remove= FALSE;
+ if(med->v1 == med->v2) {
+ PRINT(" edge %d: has matching verts, both %d\n", i, med->v1);
+ remove= do_fixes;
+ }
+ if(med->v1 >= totvert) {
+ PRINT(" edge %d: v1 index out of range, %d\n", i, med->v1);
+ remove= do_fixes;
+ }
+ if(med->v2 >= totvert) {
+ PRINT(" edge %d: v2 index out of range, %d\n", i, med->v2);
+ remove= do_fixes;
+ }
+
+ if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) {
+ PRINT(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2)));
+ remove= do_fixes;
+ }
+
+ if(remove == FALSE){
+ BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i));
+ }
+ else {
+ REMOVE_EDGE_TAG(med);
+ }
+ }
+
+ for(i=0, mf=mfaces, sf=sort_faces; i<totface; i++, mf++) {
+ int remove= FALSE;
+ int fidx;
+ unsigned int fv[4];
+
+ fidx = mf->v4 ? 3:2;
+ do {
+ fv[fidx]= *(&(mf->v1) + fidx);
+ if(fv[fidx] >= totvert) {
+ PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fv[fidx]);
+ remove= do_fixes;
+ }
+ } while (fidx--);
+
+ if(remove == FALSE) {
+ if(mf->v4) {
+ if(mf->v1 == mf->v2) { PRINT(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); remove= do_fixes; }
+ if(mf->v1 == mf->v3) { PRINT(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); remove= do_fixes; }
+ if(mf->v1 == mf->v4) { PRINT(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); remove= do_fixes; }
+
+ if(mf->v2 == mf->v3) { PRINT(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); remove= do_fixes; }
+ if(mf->v2 == mf->v4) { PRINT(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); remove= do_fixes; }
+
+ if(mf->v3 == mf->v4) { PRINT(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); remove= do_fixes; }
+ }
+ else {
+ if(mf->v1 == mf->v2) { PRINT(" faceT %d: verts invalid, v1/v2 both %d\n", i, mf->v1); remove= do_fixes; }
+ if(mf->v1 == mf->v3) { PRINT(" faceT %d: verts invalid, v1/v3 both %d\n", i, mf->v1); remove= do_fixes; }
+
+ if(mf->v2 == mf->v3) { PRINT(" faceT %d: verts invalid, v2/v3 both %d\n", i, mf->v2); remove= do_fixes; }
+ }
+
+ if(remove == FALSE) {
+ if(totedge) {
+ if(mf->v4) {
+ if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; }
+ if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; }
+ if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) { PRINT(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); do_edge_recalc= TRUE; }
+ if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) { PRINT(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); do_edge_recalc= TRUE; }
+ }
+ else {
+ if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; }
+ if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; }
+ if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) { PRINT(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); do_edge_recalc= TRUE; }
+ }
+ }
+
+ sf->index = i;
+
+ if(mf->v4) {
+ edge_store_from_mface_quad(sf->es, mf);
+
+ qsort(sf->es, 4, sizeof(int64_t), int64_cmp);
+ }
+ else {
+ edge_store_from_mface_tri(sf->es, mf);
+ qsort(sf->es, 3, sizeof(int64_t), int64_cmp);
+ }
+
+ totsortface++;
+ sf++;
+ }
+ }
+ if(remove) {
+ REMOVE_FACE_TAG(mf);
+ }
+ }
+
+ qsort(sort_faces, totsortface, sizeof(SortFace), search_face_cmp);
+
+ sf= sort_faces;
+ sf_prev= sf;
+ sf++;
+
+ for(i=1; i<totsortface; i++, sf++) {
+ int remove= FALSE;
+ /* on a valid mesh, code below will never run */
+ if(memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) {
+ mf= mfaces + sf->index;
+
+ if(do_verbose) {
+ mf_prev= mfaces + sf_prev->index;
+ if(mf->v4) {
+ PRINT(" face %d & %d: are duplicates (%d,%d,%d,%d) (%d,%d,%d,%d)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4);
+ }
+ else {
+ PRINT(" face %d & %d: are duplicates (%d,%d,%d) (%d,%d,%d)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf_prev->v1, mf_prev->v2, mf_prev->v3);
+ }
+ }
+
+ remove= do_fixes;
+ }
+ else {
+ sf_prev= sf;
+ }
+
+ if(remove) {
+ REMOVE_FACE_TAG(mf);
+ }
+ }
+
+ BLI_edgehash_free(edge_hash, NULL);
+ MEM_freeN(sort_faces);
+
+ PRINT("BKE_mesh_validate: finished\n\n");
+
+# undef PRINT
+# undef REMOVE_EDGE_TAG
+# undef REMOVE_FACE_TAG
+
+ if(me) {
+ if(do_face_free) {
+ mesh_strip_loose_faces(me);
+ }
+
+ if (do_edge_free) {
+ mesh_strip_loose_edges(me);
+ }
+
+ if(do_fixes && do_edge_recalc) {
+ BKE_mesh_calc_edges(me, TRUE);
+ }
+ }
+
+ return (do_face_free || do_edge_free || do_edge_recalc);
+}
+
+int BKE_mesh_validate(Mesh *me, int do_verbose)
+{
+ printf("MESH: %s\n", me->id.name+2);
+ return BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, do_verbose, TRUE);
+}
+
+int BKE_mesh_validate_dm(DerivedMesh *dm)
+{
+ return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm), TRUE, FALSE);
+}
+
+void BKE_mesh_calc_edges(Mesh *mesh, int update)
+{
+ CustomData edata;
+ EdgeHashIterator *ehi;
+ MFace *mf = mesh->mface;
+ MEdge *med, *med_orig;
+ EdgeHash *eh = BLI_edgehash_new();
+ int i, totedge, totface = mesh->totface;
+
+ if(mesh->totedge==0)
+ update= 0;
+
+ if(update) {
+ /* assume existing edges are valid
+ * useful when adding more faces and generating edges from them */
+ med= mesh->medge;
+ for(i= 0; i<mesh->totedge; i++, med++)
+ BLI_edgehash_insert(eh, med->v1, med->v2, med);
+ }
+
+ for (i = 0; i < totface; i++, mf++) {
+ if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2))
+ BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL);
+ if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3))
+ BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL);
+
+ if (mf->v4) {
+ if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4))
+ BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
+ if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
+ BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
+ } else {
+ if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
+ BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
+ }
+ }
+
+ totedge = BLI_edgehash_size(eh);
+
+ /* write new edges into a temporary CustomData */
+ memset(&edata, 0, sizeof(edata));
+ CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
+
+ ehi = BLI_edgehashIterator_new(eh);
+ med = CustomData_get_layer(&edata, CD_MEDGE);
+ for(i = 0; !BLI_edgehashIterator_isDone(ehi);
+ BLI_edgehashIterator_step(ehi), ++i, ++med) {
+
+ if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) {
+ *med= *med_orig; /* copy from the original */
+ } else {
+ BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
+ med->flag = ME_EDGEDRAW|ME_EDGERENDER|SELECT; /* select for newly created meshes which are selected [#25595] */
+ }
+ }
+ BLI_edgehashIterator_free(ehi);
+
+ /* free old CustomData and assign new one */
+ CustomData_free(&mesh->edata, mesh->totedge);
+ mesh->edata = edata;
+ mesh->totedge = totedge;
+
+ mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
+
+ BLI_edgehash_free(eh, NULL);
+}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 03091b9b0a4..db0c649d290 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -57,7 +57,7 @@
ModifierTypeInfo *modifierType_getInfo(ModifierType type)
{
- static ModifierTypeInfo *types[NUM_MODIFIER_TYPES];
+ static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL};
static int types_init = 1;
if (types_init) {
@@ -220,12 +220,13 @@ int modifier_sameTopology(ModifierData *md)
void modifier_setError(ModifierData *md, const char *format, ...)
{
- char buffer[2048];
+ char buffer[512];
va_list ap;
va_start(ap, format);
- vsprintf(buffer, format, ap);
+ vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
+ buffer[sizeof(buffer) - 1]= '\0';
if (md->error)
MEM_freeN(md->error);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 2a3052d10c9..29726ccbc99 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -449,7 +449,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire
static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple)
{
- MultiresModifierData mmd= {{0}};
+ MultiresModifierData mmd= {{NULL}};
mmd.lvl = lvl;
mmd.sculptlvl = lvl;
@@ -462,7 +462,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv
static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, int lvl, int simple, int optimal)
{
- SubsurfModifierData smd= {{0}};
+ SubsurfModifierData smd= {{NULL}};
smd.levels = smd.renderLevels = lvl;
smd.flags |= eSubsurfModifierFlag_SubsurfUv;
@@ -596,7 +596,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
dispdm->release(dispdm);
}
-void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple)
+static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple)
{
Mesh *me = ob->data;
MDisps *mdisps;
@@ -962,7 +962,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca
***************************/
/* Adapted from sculptmode.c */
-void old_mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float v)
+void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v)
{
int x, y, x2, y2;
const int st_max = st - 1;
@@ -1591,7 +1591,7 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob)
else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple);
}
-void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
+static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3])
{
DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL;
DMGridData **gridData, **subGridData;
@@ -1965,7 +1965,7 @@ static void face_to_crn_interp(float u, float v, float v1[2], float v2[2], float
*x = maxf(x1, x2);
}
-void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, float *u, float *v)
+void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side, const float x, const float y, float *u, float *v)
{
float offset = face_side*0.5f - 0.5f;
@@ -1992,9 +1992,9 @@ void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y,
}
}
-int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y)
+int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y)
{
- float offset = face_side*0.5f - 0.5f;
+ const float offset = face_side*0.5f - 0.5f;
int S = 0;
if (corners == 4) {
@@ -2037,7 +2037,7 @@ int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x
return S;
}
-void mdisp_apply_weight(int S, int corners, int x, int y, int face_side,
+void mdisp_apply_weight(const int S, const int corners, int x, int y, const int face_side,
float crn_weight[4][2], float *u_r, float *v_r)
{
float u, v, xl, yl;
@@ -2071,7 +2071,7 @@ void mdisp_apply_weight(int S, int corners, int x, int y, int face_side,
*v_r = mid3[1];
}
-void mdisp_flip_disp(int S, int corners, float axis_x[2], float axis_y[2], float disp[3])
+void mdisp_flip_disp(const int S, const int corners, const float axis_x[2], const float axis_y[2], float disp[3])
{
float crn_x[2], crn_y[2];
float vx[2], vy[2], coord[2];
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 6db03909aa3..da0f3f8a448 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -1320,7 +1320,7 @@ static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, fl
}
/* Determine auto-blending for the given strip */
-void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls)
+static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls)
{
float *ps=NULL, *pe=NULL;
float *ns=NULL, *ne=NULL;
@@ -1576,7 +1576,7 @@ void BKE_nla_tweakmode_exit (AnimData *adt)
/* Baking Tools ------------------------------------------- */
-void BKE_nla_bake (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag))
+static void BKE_nla_bake (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag))
{
/* verify that data is valid
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 85c82dbf9bc..057d90dc8bb 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -43,6 +43,7 @@
#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_fcurve.h"
+#include "BKE_node.h"
#include "BKE_utildefines.h"
#include "PIL_time.h"
@@ -264,22 +265,23 @@ void ntreeVerifyTypes(bNodeTree *ntree)
/* ************** Group stuff ********** */
-bNodeType node_group_typeinfo= {
- /* next,prev */ NULL, NULL,
- /* type code */ NODE_GROUP,
- /* name */ "Group",
- /* width+range */ 120, 60, 200,
- /* class+opts */ NODE_CLASS_GROUP, NODE_OPTIONS,
- /* input sock */ NULL,
- /* output sock */ NULL,
- /* storage */ "",
- /* execfunc */ NULL,
- /* butfunc */ NULL,
- /* initfunc */ NULL,
- /* freestoragefunc */ NULL,
- /* copystoragefunc */ NULL,
- /* id */ NULL
-};
+/* XXX group typeinfo struct is used directly in ntreeMakeOwnType, needs cleanup */
+static bNodeType ntype_group;
+
+/* groups display their internal tree name as label */
+static const char *group_label(bNode *node)
+{
+ return node->id->name+2;
+}
+
+void register_node_type_group(ListBase *lb)
+{
+ node_type_base(&ntype_group, NODE_GROUP, "Group", NODE_CLASS_GROUP, NODE_OPTIONS, NULL, NULL);
+ node_type_size(&ntype_group, 120, 60, 200);
+ node_type_label(&ntype_group, group_label);
+
+ nodeRegisterType(lb, &ntype_group);
+}
/* tag internal sockets */
static void group_tag_internal_sockets(bNodeTree *ngroup)
@@ -379,7 +381,7 @@ void ntreeMakeOwnType(bNodeTree *ngroup)
/* make own type struct */
ngroup->owntype= MEM_callocN(sizeof(bNodeType), "group type");
- *ngroup->owntype= node_group_typeinfo; /* copy data, for init */
+ *ngroup->owntype= ntype_group; /* copy data, for init */
/* input type arrays */
if(totin) {
@@ -824,7 +826,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode)
* - all of wgroup's nodes are transferred across to their new home
* - ngroup (i.e. the source NodeTree) is left unscathed
*/
- wgroup= ntreeCopyTree(ngroup, 0);
+ wgroup= ntreeCopyTree(ngroup);
/* add the nodes into the ntree */
for(node= wgroup->nodes.first; node; node= nextn) {
@@ -924,7 +926,7 @@ void nodeCopyGroup(bNode *gnode)
bNodeSocket *sock;
gnode->id->us--;
- gnode->id= (ID *)ntreeCopyTree((bNodeTree *)gnode->id, 0);
+ gnode->id= (ID *)ntreeCopyTree((bNodeTree *)gnode->id);
/* new_sock was set in nodeCopyNode */
for(sock=gnode->inputs.first; sock; sock=sock->next)
@@ -1189,12 +1191,11 @@ bNodeTree *ntreeAddTree(const char *name, int type, const short is_group)
}
/* Warning: this function gets called during some rather unexpected times
- * - internal_select is only 1 when used for duplicating selected nodes (i.e. Shift-D duplicate operator)
* - this gets called when executing compositing updates (for threaded previews)
* - when the nodetree datablock needs to be copied (i.e. when users get copied)
* - for scene duplication use ntreeSwapID() after so we dont have stale pointers.
*/
-bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
+bNodeTree *ntreeCopyTree(bNodeTree *ntree)
{
bNodeTree *newtree;
bNode *node, *nnode, *last;
@@ -1204,34 +1205,26 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
if(ntree==NULL) return NULL;
- if(internal_select==0) {
- /* is ntree part of library? */
- for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
- if(newtree==ntree) break;
- if(newtree) {
- newtree= copy_libblock(ntree);
- } else {
- newtree= MEM_dupallocN(ntree);
- copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */
- }
- newtree->nodes.first= newtree->nodes.last= NULL;
- newtree->links.first= newtree->links.last= NULL;
+ /* is ntree part of library? */
+ for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next)
+ if(newtree==ntree) break;
+ if(newtree) {
+ newtree= copy_libblock(ntree);
+ } else {
+ newtree= MEM_dupallocN(ntree);
+ copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */
}
- else
- newtree= ntree;
+ newtree->nodes.first= newtree->nodes.last= NULL;
+ newtree->links.first= newtree->links.last= NULL;
- last= ntree->nodes.last;
+ last = ntree->nodes.last;
for(node= ntree->nodes.first; node; node= node->next) {
-
node->new_node= NULL;
- if(internal_select==0 || (node->flag & NODE_SELECT)) {
- nnode= nodeCopyNode(newtree, node, internal_select); /* sets node->new */
- if(internal_select) {
- node->flag &= ~(NODE_SELECT|NODE_ACTIVE);
- nnode->flag |= NODE_SELECT;
- }
- }
- if(node==last) break;
+ nnode= nodeCopyNode(newtree, node, 0); /* sets node->new */
+
+ /* make sure we don't copy new nodes again! */
+ if (node==last)
+ break;
}
/* check for copying links */
@@ -1255,15 +1248,14 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select)
}
/* own type definition for group usage */
- if(internal_select==0) {
- if(ntree->owntype) {
- newtree->owntype= MEM_dupallocN(ntree->owntype);
- if(ntree->owntype->inputs)
- newtree->owntype->inputs= MEM_dupallocN(ntree->owntype->inputs);
- if(ntree->owntype->outputs)
- newtree->owntype->outputs= MEM_dupallocN(ntree->owntype->outputs);
- }
+ if(ntree->owntype) {
+ newtree->owntype= MEM_dupallocN(ntree->owntype);
+ if(ntree->owntype->inputs)
+ newtree->owntype->inputs= MEM_dupallocN(ntree->owntype->inputs);
+ if(ntree->owntype->outputs)
+ newtree->owntype->outputs= MEM_dupallocN(ntree->owntype->outputs);
}
+
/* weird this is required... there seem to be link pointers wrong still? */
/* anyhoo, doing this solves crashes on copying entire tree (copy scene) and delete nodes */
ntreeSolveOrder(newtree);
@@ -1507,9 +1499,9 @@ void ntreeMakeLocal(bNodeTree *ntree)
if(ntree->id.lib==NULL) return;
if(ntree->id.us==1) {
- ntree->id.lib= 0;
+ ntree->id.lib= NULL;
ntree->id.flag= LIB_LOCAL;
- new_id(0, (ID *)ntree, 0);
+ new_id(NULL, (ID *)ntree, NULL);
return;
}
@@ -1567,11 +1559,11 @@ void ntreeMakeLocal(bNodeTree *ntree)
if(local && lib==0) {
ntree->id.lib= NULL;
ntree->id.flag= LIB_LOCAL;
- new_id(0, (ID *)ntree, 0);
+ new_id(NULL, (ID *)ntree, NULL);
}
else if(local && lib) {
/* this is the mixed case, we copy the tree and assign it to local users */
- bNodeTree *newtree= ntreeCopyTree(ntree, 0);
+ bNodeTree *newtree= ntreeCopyTree(ntree);
newtree->id.us= 0;
@@ -2445,7 +2437,7 @@ static void *exec_composite_node(void *node_v)
}
node->exec |= NODE_READY;
- return 0;
+ return NULL;
}
/* return total of executable nodes, for timecursor */
@@ -2739,7 +2731,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree)
}
/* node copy func */
- ltree= ntreeCopyTree(ntree, 0);
+ ltree= ntreeCopyTree(ntree);
if(adt) {
AnimData *ladt= BKE_animdata_from_id(&ltree->id);
@@ -3181,10 +3173,7 @@ int ntreeCompositTagAnimated(bNodeTree *ntree)
NodeTagChanged(ntree, node);
tagged= 1;
}
- else if(node->type==CMP_NODE_R_LAYERS) {
- NodeTagChanged(ntree, node);
- tagged= 1;
- }
+ /* here was tag render layer, but this is called after a render, so re-composites fail */
else if(node->type==NODE_GROUP) {
if( ntreeCompositTagAnimated((bNodeTree *)node->id) ) {
NodeTagChanged(ntree, node);
@@ -3209,6 +3198,21 @@ void ntreeCompositTagGenerators(bNodeTree *ntree)
}
}
+/* XXX after render animation system gets a refresh, this call allows composite to end clean */
+void ntreeClearTags(bNodeTree *ntree)
+{
+ bNode *node;
+
+ if(ntree==NULL) return;
+
+ for(node= ntree->nodes.first; node; node= node->next) {
+ node->need_exec= 0;
+ if(node->type==NODE_GROUP)
+ ntreeClearTags((bNodeTree *)node->id);
+ }
+}
+
+
int ntreeTexTagAnimated(bNodeTree *ntree)
{
bNode *node;
@@ -3232,6 +3236,62 @@ int ntreeTexTagAnimated(bNodeTree *ntree)
/* ************* node definition init ********** */
+void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag,
+ struct bNodeSocketType *inputs, struct bNodeSocketType *outputs)
+{
+ memset(ntype, 0, sizeof(bNodeType));
+
+ ntype->type = type;
+ ntype->name = name;
+ ntype->nclass = nclass;
+ ntype->flag = flag;
+
+ ntype->inputs = inputs;
+ ntype->outputs = outputs;
+
+ /* default size values */
+ ntype->width = 140;
+ ntype->minwidth = 100;
+ ntype->maxwidth = 320;
+}
+
+void node_type_init(bNodeType *ntype, void (*initfunc)(struct bNode *))
+{
+ ntype->initfunc = initfunc;
+}
+
+void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth)
+{
+ ntype->width = width;
+ ntype->minwidth = minwidth;
+ ntype->maxwidth = maxwidth;
+}
+
+void node_type_storage(bNodeType *ntype, const char *storagename, void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *))
+{
+ if (storagename)
+ strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
+ else
+ ntype->storagename[0] = '\0';
+ ntype->copystoragefunc = copystoragefunc;
+ ntype->freestoragefunc = freestoragefunc;
+}
+
+void node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **))
+{
+ ntype->execfunc = execfunc;
+}
+
+void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out))
+{
+ ntype->gpufunc = gpufunc;
+}
+
+void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *))
+{
+ ntype->labelfunc = labelfunc;
+}
+
static bNodeType *is_nodetype_registered(ListBase *typelist, int type, ID *id)
{
bNodeType *ntype= typelist->first;
@@ -3257,147 +3317,150 @@ void nodeRegisterType(ListBase *typelist, const bNodeType *ntype)
static void registerCompositNodes(ListBase *ntypelist)
{
- nodeRegisterType(ntypelist, &node_group_typeinfo);
- nodeRegisterType(ntypelist, &cmp_node_rlayers);
- nodeRegisterType(ntypelist, &cmp_node_image);
- nodeRegisterType(ntypelist, &cmp_node_texture);
- nodeRegisterType(ntypelist, &cmp_node_value);
- nodeRegisterType(ntypelist, &cmp_node_rgb);
- nodeRegisterType(ntypelist, &cmp_node_curve_time);
-
- nodeRegisterType(ntypelist, &cmp_node_composite);
- nodeRegisterType(ntypelist, &cmp_node_viewer);
- nodeRegisterType(ntypelist, &cmp_node_splitviewer);
- nodeRegisterType(ntypelist, &cmp_node_output_file);
- nodeRegisterType(ntypelist, &cmp_node_view_levels);
-
- nodeRegisterType(ntypelist, &cmp_node_curve_rgb);
- nodeRegisterType(ntypelist, &cmp_node_mix_rgb);
- nodeRegisterType(ntypelist, &cmp_node_hue_sat);
- nodeRegisterType(ntypelist, &cmp_node_brightcontrast);
- nodeRegisterType(ntypelist, &cmp_node_gamma);
- nodeRegisterType(ntypelist, &cmp_node_invert);
- nodeRegisterType(ntypelist, &cmp_node_alphaover);
- nodeRegisterType(ntypelist, &cmp_node_zcombine);
- nodeRegisterType(ntypelist, &cmp_node_colorbalance);
- nodeRegisterType(ntypelist, &cmp_node_huecorrect);
-
- nodeRegisterType(ntypelist, &cmp_node_normal);
- nodeRegisterType(ntypelist, &cmp_node_curve_vec);
- nodeRegisterType(ntypelist, &cmp_node_map_value);
- nodeRegisterType(ntypelist, &cmp_node_normalize);
-
- nodeRegisterType(ntypelist, &cmp_node_filter);
- nodeRegisterType(ntypelist, &cmp_node_blur);
- nodeRegisterType(ntypelist, &cmp_node_dblur);
- nodeRegisterType(ntypelist, &cmp_node_bilateralblur);
- nodeRegisterType(ntypelist, &cmp_node_vecblur);
- nodeRegisterType(ntypelist, &cmp_node_dilateerode);
- nodeRegisterType(ntypelist, &cmp_node_defocus);
-
- nodeRegisterType(ntypelist, &cmp_node_valtorgb);
- nodeRegisterType(ntypelist, &cmp_node_rgbtobw);
- nodeRegisterType(ntypelist, &cmp_node_setalpha);
- nodeRegisterType(ntypelist, &cmp_node_idmask);
- nodeRegisterType(ntypelist, &cmp_node_math);
- nodeRegisterType(ntypelist, &cmp_node_seprgba);
- nodeRegisterType(ntypelist, &cmp_node_combrgba);
- nodeRegisterType(ntypelist, &cmp_node_sephsva);
- nodeRegisterType(ntypelist, &cmp_node_combhsva);
- nodeRegisterType(ntypelist, &cmp_node_sepyuva);
- nodeRegisterType(ntypelist, &cmp_node_combyuva);
- nodeRegisterType(ntypelist, &cmp_node_sepycca);
- nodeRegisterType(ntypelist, &cmp_node_combycca);
- nodeRegisterType(ntypelist, &cmp_node_premulkey);
-
- nodeRegisterType(ntypelist, &cmp_node_diff_matte);
- nodeRegisterType(ntypelist, &cmp_node_distance_matte);
- nodeRegisterType(ntypelist, &cmp_node_chroma_matte);
- nodeRegisterType(ntypelist, &cmp_node_color_matte);
- nodeRegisterType(ntypelist, &cmp_node_channel_matte);
- nodeRegisterType(ntypelist, &cmp_node_color_spill);
- nodeRegisterType(ntypelist, &cmp_node_luma_matte);
-
- nodeRegisterType(ntypelist, &cmp_node_translate);
- nodeRegisterType(ntypelist, &cmp_node_rotate);
- nodeRegisterType(ntypelist, &cmp_node_scale);
- nodeRegisterType(ntypelist, &cmp_node_flip);
- nodeRegisterType(ntypelist, &cmp_node_crop);
- nodeRegisterType(ntypelist, &cmp_node_displace);
- nodeRegisterType(ntypelist, &cmp_node_mapuv);
- nodeRegisterType(ntypelist, &cmp_node_glare);
- nodeRegisterType(ntypelist, &cmp_node_tonemap);
- nodeRegisterType(ntypelist, &cmp_node_lensdist);
+ register_node_type_group(ntypelist);
+
+ register_node_type_cmp_rlayers(ntypelist);
+ register_node_type_cmp_image(ntypelist);
+ register_node_type_cmp_texture(ntypelist);
+ register_node_type_cmp_value(ntypelist);
+ register_node_type_cmp_rgb(ntypelist);
+ register_node_type_cmp_curve_time(ntypelist);
+
+ register_node_type_cmp_composite(ntypelist);
+ register_node_type_cmp_viewer(ntypelist);
+ register_node_type_cmp_splitviewer(ntypelist);
+ register_node_type_cmp_output_file(ntypelist);
+ register_node_type_cmp_view_levels(ntypelist);
+
+ register_node_type_cmp_curve_rgb(ntypelist);
+ register_node_type_cmp_mix_rgb(ntypelist);
+ register_node_type_cmp_hue_sat(ntypelist);
+ register_node_type_cmp_brightcontrast(ntypelist);
+ register_node_type_cmp_gamma(ntypelist);
+ register_node_type_cmp_invert(ntypelist);
+ register_node_type_cmp_alphaover(ntypelist);
+ register_node_type_cmp_zcombine(ntypelist);
+ register_node_type_cmp_colorbalance(ntypelist);
+ register_node_type_cmp_huecorrect(ntypelist);
+
+ register_node_type_cmp_normal(ntypelist);
+ register_node_type_cmp_curve_vec(ntypelist);
+ register_node_type_cmp_map_value(ntypelist);
+ register_node_type_cmp_normalize(ntypelist);
+
+ register_node_type_cmp_filter(ntypelist);
+ register_node_type_cmp_blur(ntypelist);
+ register_node_type_cmp_dblur(ntypelist);
+ register_node_type_cmp_bilateralblur(ntypelist);
+ register_node_type_cmp_vecblur(ntypelist);
+ register_node_type_cmp_dilateerode(ntypelist);
+ register_node_type_cmp_defocus(ntypelist);
+
+ register_node_type_cmp_valtorgb(ntypelist);
+ register_node_type_cmp_rgbtobw(ntypelist);
+ register_node_type_cmp_setalpha(ntypelist);
+ register_node_type_cmp_idmask(ntypelist);
+ register_node_type_cmp_math(ntypelist);
+ register_node_type_cmp_seprgba(ntypelist);
+ register_node_type_cmp_combrgba(ntypelist);
+ register_node_type_cmp_sephsva(ntypelist);
+ register_node_type_cmp_combhsva(ntypelist);
+ register_node_type_cmp_sepyuva(ntypelist);
+ register_node_type_cmp_combyuva(ntypelist);
+ register_node_type_cmp_sepycca(ntypelist);
+ register_node_type_cmp_combycca(ntypelist);
+ register_node_type_cmp_premulkey(ntypelist);
+
+ register_node_type_cmp_diff_matte(ntypelist);
+ register_node_type_cmp_distance_matte(ntypelist);
+ register_node_type_cmp_chroma_matte(ntypelist);
+ register_node_type_cmp_color_matte(ntypelist);
+ register_node_type_cmp_channel_matte(ntypelist);
+ register_node_type_cmp_color_spill(ntypelist);
+ register_node_type_cmp_luma_matte(ntypelist);
+
+ register_node_type_cmp_translate(ntypelist);
+ register_node_type_cmp_rotate(ntypelist);
+ register_node_type_cmp_scale(ntypelist);
+ register_node_type_cmp_flip(ntypelist);
+ register_node_type_cmp_crop(ntypelist);
+ register_node_type_cmp_displace(ntypelist);
+ register_node_type_cmp_mapuv(ntypelist);
+ register_node_type_cmp_glare(ntypelist);
+ register_node_type_cmp_tonemap(ntypelist);
+ register_node_type_cmp_lensdist(ntypelist);
}
static void registerShaderNodes(ListBase *ntypelist)
{
- nodeRegisterType(ntypelist, &node_group_typeinfo);
- nodeRegisterType(ntypelist, &sh_node_output);
- nodeRegisterType(ntypelist, &sh_node_mix_rgb);
- nodeRegisterType(ntypelist, &sh_node_valtorgb);
- nodeRegisterType(ntypelist, &sh_node_rgbtobw);
- nodeRegisterType(ntypelist, &sh_node_normal);
- nodeRegisterType(ntypelist, &sh_node_geom);
- nodeRegisterType(ntypelist, &sh_node_mapping);
- nodeRegisterType(ntypelist, &sh_node_curve_vec);
- nodeRegisterType(ntypelist, &sh_node_curve_rgb);
- nodeRegisterType(ntypelist, &sh_node_math);
- nodeRegisterType(ntypelist, &sh_node_vect_math);
- nodeRegisterType(ntypelist, &sh_node_squeeze);
- nodeRegisterType(ntypelist, &sh_node_camera);
- nodeRegisterType(ntypelist, &sh_node_material);
- nodeRegisterType(ntypelist, &sh_node_material_ext);
- nodeRegisterType(ntypelist, &sh_node_value);
- nodeRegisterType(ntypelist, &sh_node_rgb);
- nodeRegisterType(ntypelist, &sh_node_texture);
- nodeRegisterType(ntypelist, &node_dynamic_typeinfo);
- nodeRegisterType(ntypelist, &sh_node_invert);
- nodeRegisterType(ntypelist, &sh_node_seprgb);
- nodeRegisterType(ntypelist, &sh_node_combrgb);
- nodeRegisterType(ntypelist, &sh_node_hue_sat);
+ register_node_type_group(ntypelist);
+
+ register_node_type_sh_output(ntypelist);
+ register_node_type_sh_mix_rgb(ntypelist);
+ register_node_type_sh_valtorgb(ntypelist);
+ register_node_type_sh_rgbtobw(ntypelist);
+ register_node_type_sh_normal(ntypelist);
+ register_node_type_sh_geom(ntypelist);
+ register_node_type_sh_mapping(ntypelist);
+ register_node_type_sh_curve_vec(ntypelist);
+ register_node_type_sh_curve_rgb(ntypelist);
+ register_node_type_sh_math(ntypelist);
+ register_node_type_sh_vect_math(ntypelist);
+ register_node_type_sh_squeeze(ntypelist);
+ register_node_type_sh_camera(ntypelist);
+ register_node_type_sh_material(ntypelist);
+ register_node_type_sh_material_ext(ntypelist);
+ register_node_type_sh_value(ntypelist);
+ register_node_type_sh_rgb(ntypelist);
+ register_node_type_sh_texture(ntypelist);
+ register_node_type_sh_dynamic(ntypelist);
+ register_node_type_sh_invert(ntypelist);
+ register_node_type_sh_seprgb(ntypelist);
+ register_node_type_sh_combrgb(ntypelist);
+ register_node_type_sh_hue_sat(ntypelist);
}
static void registerTextureNodes(ListBase *ntypelist)
{
- nodeRegisterType(ntypelist, &node_group_typeinfo);
- nodeRegisterType(ntypelist, &tex_node_math);
- nodeRegisterType(ntypelist, &tex_node_mix_rgb);
- nodeRegisterType(ntypelist, &tex_node_valtorgb);
- nodeRegisterType(ntypelist, &tex_node_rgbtobw);
- nodeRegisterType(ntypelist, &tex_node_valtonor);
- nodeRegisterType(ntypelist, &tex_node_curve_rgb);
- nodeRegisterType(ntypelist, &tex_node_curve_time);
- nodeRegisterType(ntypelist, &tex_node_invert);
- nodeRegisterType(ntypelist, &tex_node_hue_sat);
- nodeRegisterType(ntypelist, &tex_node_coord);
- nodeRegisterType(ntypelist, &tex_node_distance);
- nodeRegisterType(ntypelist, &tex_node_compose);
- nodeRegisterType(ntypelist, &tex_node_decompose);
-
- nodeRegisterType(ntypelist, &tex_node_output);
- nodeRegisterType(ntypelist, &tex_node_viewer);
-
- nodeRegisterType(ntypelist, &tex_node_checker);
- nodeRegisterType(ntypelist, &tex_node_texture);
- nodeRegisterType(ntypelist, &tex_node_bricks);
- nodeRegisterType(ntypelist, &tex_node_image);
-
- nodeRegisterType(ntypelist, &tex_node_rotate);
- nodeRegisterType(ntypelist, &tex_node_translate);
- nodeRegisterType(ntypelist, &tex_node_scale);
- nodeRegisterType(ntypelist, &tex_node_at);
-
- nodeRegisterType(ntypelist, &tex_node_proc_voronoi);
- nodeRegisterType(ntypelist, &tex_node_proc_blend);
- nodeRegisterType(ntypelist, &tex_node_proc_magic);
- nodeRegisterType(ntypelist, &tex_node_proc_marble);
- nodeRegisterType(ntypelist, &tex_node_proc_clouds);
- nodeRegisterType(ntypelist, &tex_node_proc_wood);
- nodeRegisterType(ntypelist, &tex_node_proc_musgrave);
- nodeRegisterType(ntypelist, &tex_node_proc_noise);
- nodeRegisterType(ntypelist, &tex_node_proc_stucci);
- nodeRegisterType(ntypelist, &tex_node_proc_distnoise);
+ register_node_type_group(ntypelist);
+
+ register_node_type_tex_math(ntypelist);
+ register_node_type_tex_mix_rgb(ntypelist);
+ register_node_type_tex_valtorgb(ntypelist);
+ register_node_type_tex_rgbtobw(ntypelist);
+ register_node_type_tex_valtonor(ntypelist);
+ register_node_type_tex_curve_rgb(ntypelist);
+ register_node_type_tex_curve_time(ntypelist);
+ register_node_type_tex_invert(ntypelist);
+ register_node_type_tex_hue_sat(ntypelist);
+ register_node_type_tex_coord(ntypelist);
+ register_node_type_tex_distance(ntypelist);
+ register_node_type_tex_compose(ntypelist);
+ register_node_type_tex_decompose(ntypelist);
+
+ register_node_type_tex_output(ntypelist);
+ register_node_type_tex_viewer(ntypelist);
+
+ register_node_type_tex_checker(ntypelist);
+ register_node_type_tex_texture(ntypelist);
+ register_node_type_tex_bricks(ntypelist);
+ register_node_type_tex_image(ntypelist);
+
+ register_node_type_tex_rotate(ntypelist);
+ register_node_type_tex_translate(ntypelist);
+ register_node_type_tex_scale(ntypelist);
+ register_node_type_tex_at(ntypelist);
+
+ register_node_type_tex_proc_voronoi(ntypelist);
+ register_node_type_tex_proc_blend(ntypelist);
+ register_node_type_tex_proc_magic(ntypelist);
+ register_node_type_tex_proc_marble(ntypelist);
+ register_node_type_tex_proc_clouds(ntypelist);
+ register_node_type_tex_proc_wood(ntypelist);
+ register_node_type_tex_proc_musgrave(ntypelist);
+ register_node_type_tex_proc_noise(ntypelist);
+ register_node_type_tex_proc_stucci(ntypelist);
+ register_node_type_tex_proc_distnoise(ntypelist);
}
static void remove_dynamic_typeinfos(ListBase *list)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 860ced6de0b..684f1531114 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -275,7 +275,7 @@ void free_object(Object *ob)
else if(ob->type==OB_CURVE) unlink_curve(ob->data);
else if(ob->type==OB_MBALL) unlink_mball(ob->data);
}
- ob->data= 0;
+ ob->data= NULL;
}
for(a=0; a<ob->totcol; a++) {
@@ -283,12 +283,12 @@ void free_object(Object *ob)
}
if(ob->mat) MEM_freeN(ob->mat);
if(ob->matbits) MEM_freeN(ob->matbits);
- ob->mat= 0;
- ob->matbits= 0;
+ ob->mat= NULL;
+ ob->matbits= NULL;
if(ob->bb) MEM_freeN(ob->bb);
- ob->bb= 0;
+ ob->bb= NULL;
if(ob->path) free_path(ob->path);
- ob->path= 0;
+ ob->path= NULL;
if(ob->adt) BKE_free_animdata((ID *)ob);
if(ob->poselib) ob->poselib->id.us--;
if(ob->gpd) ((ID *)ob->gpd)->us--;
@@ -749,11 +749,11 @@ void make_local_camera(Camera *cam)
* - mixed: make copy
*/
- if(cam->id.lib==0) return;
+ if(cam->id.lib==NULL) return;
if(cam->id.us==1) {
- cam->id.lib= 0;
+ cam->id.lib= NULL;
cam->id.flag= LIB_LOCAL;
- new_id(0, (ID *)cam, 0);
+ new_id(NULL, (ID *)cam, NULL);
return;
}
@@ -767,9 +767,9 @@ void make_local_camera(Camera *cam)
}
if(local && lib==0) {
- cam->id.lib= 0;
+ cam->id.lib= NULL;
cam->id.flag= LIB_LOCAL;
- new_id(0, (ID *)cam, 0);
+ new_id(NULL, (ID *)cam, NULL);
}
else if(local && lib) {
camn= copy_camera(cam);
@@ -779,7 +779,7 @@ void make_local_camera(Camera *cam)
while(ob) {
if(ob->data==cam) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= camn;
camn->id.us++;
cam->id.us--;
@@ -898,11 +898,11 @@ void make_local_lamp(Lamp *la)
* - mixed: make copy
*/
- if(la->id.lib==0) return;
+ if(la->id.lib==NULL) return;
if(la->id.us==1) {
- la->id.lib= 0;
+ la->id.lib= NULL;
la->id.flag= LIB_LOCAL;
- new_id(0, (ID *)la, 0);
+ new_id(NULL, (ID *)la, NULL);
return;
}
@@ -916,9 +916,9 @@ void make_local_lamp(Lamp *la)
}
if(local && lib==0) {
- la->id.lib= 0;
+ la->id.lib= NULL;
la->id.flag= LIB_LOCAL;
- new_id(0, (ID *)la, 0);
+ new_id(NULL, (ID *)la, NULL);
}
else if(local && lib) {
lan= copy_lamp(la);
@@ -928,7 +928,7 @@ void make_local_lamp(Lamp *la)
while(ob) {
if(ob->data==la) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= lan;
lan->id.us++;
la->id.us--;
@@ -1088,7 +1088,7 @@ Object *add_object(struct Scene *scene, int type)
Base *base;
char name[32];
- strcpy(name, get_obdata_defname(type));
+ BLI_strncpy(name, get_obdata_defname(type), sizeof(name));
ob = add_only_object(type, name);
ob->data= add_obdata_from_type(type);
@@ -1137,7 +1137,7 @@ BulletSoftBody *copy_bulletsoftbody(BulletSoftBody *bsb)
return bsbn;
}
-ParticleSystem *copy_particlesystem(ParticleSystem *psys)
+static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
{
ParticleSystem *psysn;
ParticleData *pa;
@@ -2272,7 +2272,7 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob)
where_is_object(scene, workob);
}
-BoundBox *unit_boundbox()
+BoundBox *unit_boundbox(void)
{
BoundBox *bb;
float min[3] = {-1.0f,-1.0f,-1.0f}, max[3] = {-1.0f,-1.0f,-1.0f};
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 12ebaf7578a..1fc0a2259fb 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -459,7 +459,7 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how)
if (newname != NULL) {
ret_value = RET_OK;
freePackedFile(vfont->packedfile);
- vfont->packedfile = 0;
+ vfont->packedfile = NULL;
strcpy(vfont->name, newname);
MEM_freeN(newname);
}
@@ -485,7 +485,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how)
MEM_freeN(newname);
freePackedFile(sound->packedfile);
- sound->packedfile = 0;
+ sound->packedfile = NULL;
sound_load(bmain, sound);
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index f6b97dcb78e..d1d5c13c3dd 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -77,8 +77,6 @@
#include "RE_render_ext.h"
-static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index,
- float *fuv, float *orco, ParticleTexture *ptex, int event);
static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx,
ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex);
static void do_child_modifiers(ParticleSimulationData *sim,
@@ -159,21 +157,21 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf
ParticleSystem *psys_get_current(Object *ob)
{
ParticleSystem *psys;
- if(ob==0) return 0;
+ if(ob==NULL) return NULL;
for(psys=ob->particlesystem.first; psys; psys=psys->next){
if(psys->flag & PSYS_CURRENT)
return psys;
}
- return 0;
+ return NULL;
}
short psys_get_current_num(Object *ob)
{
ParticleSystem *psys;
short i;
- if(ob==0) return 0;
+ if(ob==NULL) return 0;
for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++)
if(psys->flag & PSYS_CURRENT)
@@ -186,7 +184,7 @@ void psys_set_current_num(Object *ob, int index)
ParticleSystem *psys;
short i;
- if(ob==0) return;
+ if(ob==NULL) return;
for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) {
if(i == index)
@@ -211,7 +209,7 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys)
}
Object *psys_get_lattice(ParticleSimulationData *sim)
{
- Object *lattice=0;
+ Object *lattice=NULL;
if(psys_in_edit_mode(sim->scene, sim->psys)==0){
@@ -225,7 +223,7 @@ Object *psys_get_lattice(ParticleSimulationData *sim)
}
}
if(lattice)
- init_latt_deform(lattice,0);
+ init_latt_deform(lattice, NULL);
}
return lattice;
@@ -360,7 +358,7 @@ int psys_uses_gravity(ParticleSimulationData *sim)
/************************************************/
/* Freeing stuff */
/************************************************/
-void fluid_free_settings(SPHFluidSettings *fluid)
+static void fluid_free_settings(SPHFluidSettings *fluid)
{
if(fluid)
MEM_freeN(fluid);
@@ -368,6 +366,8 @@ void fluid_free_settings(SPHFluidSettings *fluid)
void psys_free_settings(ParticleSettings *part)
{
+ MTex *mtex;
+ int a;
BKE_free_animdata(&part->id);
free_partdeflect(part->pd);
free_partdeflect(part->pd2);
@@ -379,6 +379,12 @@ void psys_free_settings(ParticleSettings *part)
boid_free_settings(part->boids);
fluid_free_settings(part->fluid);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ mtex= part->mtex[a];
+ if(mtex && mtex->tex) mtex->tex->id.us--;
+ if(mtex) MEM_freeN(mtex);
+ }
}
void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
@@ -461,7 +467,7 @@ void psys_free_children(ParticleSystem *psys)
{
if(psys->child) {
MEM_freeN(psys->child);
- psys->child=0;
+ psys->child= NULL;
psys->totchild=0;
}
@@ -531,7 +537,7 @@ void psys_free(Object *ob, ParticleSystem * psys)
if(psys->child){
MEM_freeN(psys->child);
- psys->child = 0;
+ psys->child = NULL;
psys->totchild = 0;
}
@@ -552,7 +558,7 @@ void psys_free(Object *ob, ParticleSystem * psys)
if(psys->part){
psys->part->id.us--;
- psys->part=0;
+ psys->part=NULL;
}
BKE_ptcache_free_list(&psys->ptcaches);
@@ -2246,12 +2252,13 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK
normalize_v3(force);
- VECADDFAC(ca->co, (ca-1)->co, force, *length);
-
- if(k < steps) {
+ if(k < steps)
sub_v3_v3v3(vec, (ca+1)->co, ca->co);
+
+ madd_v3_v3v3fl(ca->co, (ca-1)->co, force, *length);
+
+ if(k < steps)
*length = len_v3(vec);
- }
}
static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec)
{
@@ -2859,11 +2866,12 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
Material *ma;
ParticleInterpolationData pind;
+ ParticleTexture ptex;
PARTICLE_P;
float birthtime = 0.0, dietime = 0.0;
- float t, time = 0.0, dfra = 1.0, frs_sec = sim->scene->r.frs_sec;
+ float t, time = 0.0, dfra = 1.0 /* , frs_sec = sim->scene->r.frs_sec*/ /*UNUSED*/;
float col[4] = {0.5f, 0.5f, 0.5f, 1.0f};
float prev_tangent[3] = {0.0f, 0.0f, 0.0f}, hairmat[4][4];
float rotmat[3][3];
@@ -2908,8 +2916,8 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
/*---first main loop: create all actual particles' paths---*/
LOOP_SHOWN_PARTICLES {
if(!psys->totchild) {
- BLI_srandom(psys->seed + p);
- pa_length = 1.0f - part->randlength * BLI_frand();
+ psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f);
+ pa_length = ptex.length * (1.0f - part->randlength * PSYS_FRAND(psys->seed + p));
if(vg_length)
pa_length *= psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_length);
}
@@ -3472,7 +3480,7 @@ static void default_particle_settings(ParticleSettings *part)
part->bb_uv_split=1;
part->bb_align=PART_BB_VIEW;
part->bb_split_offset=PART_BB_OFF_LINEAR;
- part->flag=PART_EDISTR|PART_TRAND;
+ part->flag=PART_EDISTR|PART_TRAND|PART_HIDE_ADVANCED_HAIR;
part->sta= 1.0;
part->end= 200.0;
@@ -3498,8 +3506,6 @@ static void default_particle_settings(ParticleSettings *part)
part->normfac= 1.0f;
- part->reactshape=1.0f;
-
part->mass=1.0;
part->size=0.05;
part->childsize=1.0;
@@ -3673,82 +3679,128 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, fl
return 1;
}
-static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float *fw, float *orco, ParticleTexture *ptex, int event)
+#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend);}
+#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if(event & type) { if(pvalue < 0.f) pvalue = 1.f+pvalue; CLAMP(pvalue, 0.0, 1.0); }
+#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) if(event & type) { CLAMP(pvalue, -1.0, 1.0); }
+
+static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, float *fw, float *orco, ParticleTexture *ptex, int event, float cfra)
{
- MTex *mtex;
- int m,setvars=0;
- float value, rgba[4], texco[3];
+ MTex *mtex, **mtexp = part->mtex;
+ int m;
+ float value, rgba[4], texvec[3];
- if(ma) for(m=0; m<MAX_MTEX; m++){
- mtex=ma->mtex[m];
- if(mtex && (ma->septex & (1<<m))==0 && mtex->pmapto){
+ ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp =
+ ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink =
+ ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f;
+
+ ptex->length= 1.0f - part->randlength * PSYS_FRAND(child_index + 26);
+ ptex->length*= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f;
+
+ for(m=0; m<MAX_MTEX; m++, mtexp++){
+ mtex = *mtexp;
+ if(mtex && mtex->mapto){
float def=mtex->def_var;
short blend=mtex->blendtype;
+ short texco = mtex->texco;
- if((mtex->texco & TEXCO_UV) && fw) {
- if(!get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texco))
- VECCOPY(texco,orco);
- }
- else
- VECCOPY(texco,orco);
+ if(ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
+ texco = TEXCO_GLOB;
- externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
- if((event & mtex->pmapto) & MAP_PA_TIME){
- if((setvars&MAP_PA_TIME)==0){
- ptex->time=0.0;
- setvars|=MAP_PA_TIME;
- }
- ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,mtex->timefac,blend);
+ switch(texco) {
+ case TEXCO_GLOB:
+ copy_v3_v3(texvec, par->state.co);
+ break;
+ case TEXCO_OBJECT:
+ copy_v3_v3(texvec, par->state.co);
+ if(mtex->object)
+ mul_m4_v3(mtex->object->imat, texvec);
+ break;
+ case TEXCO_UV:
+ if(fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec))
+ break;
+ /* no break, failed to get uv's, so let's try orco's */
+ case TEXCO_ORCO:
+ copy_v3_v3(texvec, orco);
+ break;
+ case TEXCO_PARTICLE:
+ /* texture coordinates in range [-1,1] */
+ texvec[0] = 2.f * (cfra - par->time)/(par->dietime-par->time) - 1.f;
+ texvec[1] = 0.f;
+ texvec[2] = 0.f;
+ break;
}
- if((event & mtex->pmapto) & MAP_PA_LENGTH)
- ptex->length= texture_value_blend(def,ptex->length,value,mtex->lengthfac,blend);
- if((event & mtex->pmapto) & MAP_PA_CLUMP)
- ptex->clump= texture_value_blend(def,ptex->clump,value,mtex->clumpfac,blend);
- if((event & mtex->pmapto) & MAP_PA_KINK)
- ptex->kink= texture_value_blend(def,ptex->kink,value,mtex->kinkfac,blend);
- if((event & mtex->pmapto) & MAP_PA_ROUGH)
+
+ externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
+
+ if((event & mtex->mapto) & PAMAP_ROUGH)
ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,mtex->roughfac,blend);
- if((event & mtex->pmapto) & MAP_PA_DENS)
- ptex->exist= texture_value_blend(def,ptex->exist,value,mtex->padensfac,blend);
+
+ SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac);
+ SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac);
+ SET_PARTICLE_TEXTURE(PAMAP_KINK, ptex->kink, mtex->kinkfac);
+ SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac);
}
}
- if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
- if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); }
- if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); }
- if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); }
- if(event & MAP_PA_ROUGH) {
- CLAMP(ptex->rough1,0.0,1.0);
- CLAMP(ptex->rough2,0.0,1.0);
- CLAMP(ptex->roughe,0.0,1.0);
- }
- if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); }
+
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length);
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_CLUMP, ptex->clump);
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_KINK, ptex->kink);
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_ROUGH, ptex->rough1);
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist);
}
-void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *pa, ParticleTexture *ptex, int event)
+void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTexture *ptex, int event, float cfra)
{
+ ParticleSettings *part = sim->psys->part;
+ MTex **mtexp = part->mtex;
MTex *mtex;
int m;
- float value, rgba[4], co[3], texco[3];
+ float value, rgba[4], co[3], texvec[3];
int setvars=0;
- if(ma) for(m=0; m<MAX_MTEX; m++){
- mtex=ma->mtex[m];
- if(mtex && (ma->septex & (1<<m))==0 && mtex->pmapto){
+ /* initialize ptex */
+ ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp =
+ ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink =
+ ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f;
+
+ ptex->time = (float)(pa - sim->psys->particles)/(float)sim->psys->totpart;
+
+ for(m=0; m<MAX_MTEX; m++, mtexp++){
+ mtex = *mtexp;
+ if(mtex && mtex->mapto){
float def=mtex->def_var;
short blend=mtex->blendtype;
+ short texco = mtex->texco;
- if((mtex->texco & TEXCO_UV) && ELEM(sim->psys->part->from, PART_FROM_FACE, PART_FROM_VOLUME)) {
- if(!get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texco)) {
- /* failed to get uv's, let's try orco's */
- psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0);
- }
- }
- else {
- psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0);
+ if(ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID))
+ texco = TEXCO_GLOB;
+
+ switch(texco) {
+ case TEXCO_GLOB:
+ copy_v3_v3(texvec, pa->state.co);
+ break;
+ case TEXCO_OBJECT:
+ copy_v3_v3(texvec, pa->state.co);
+ if(mtex->object)
+ mul_m4_v3(mtex->object->imat, texvec);
+ break;
+ case TEXCO_UV:
+ if(get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec))
+ break;
+ /* no break, failed to get uv's, so let's try orco's */
+ case TEXCO_ORCO:
+ psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texvec, 0);
+ break;
+ case TEXCO_PARTICLE:
+ /* texture coordinates in range [-1,1] */
+ texvec[0] = 2.f * (cfra - pa->time)/(pa->dietime-pa->time) - 1.f;
+ texvec[1] = 0.f;
+ texvec[2] = 0.f;
+ break;
}
- externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
+ externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0);
- if((event & mtex->pmapto) & MAP_PA_TIME){
+ if((event & mtex->mapto) & PAMAP_TIME) {
/* the first time has to set the base value for time regardless of blend mode */
if((setvars&MAP_PA_TIME)==0){
int flip= (mtex->timefac < 0.0f);
@@ -3760,32 +3812,26 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p
else
ptex->time= texture_value_blend(def,ptex->time,value,mtex->timefac,blend);
}
- if((event & mtex->pmapto) & MAP_PA_LIFE)
- ptex->life= texture_value_blend(def,ptex->life,value,mtex->lifefac,blend);
- if((event & mtex->pmapto) & MAP_PA_DENS)
- ptex->exist= texture_value_blend(def,ptex->exist,value,mtex->padensfac,blend);
- if((event & mtex->pmapto) & MAP_PA_SIZE)
- ptex->size= texture_value_blend(def,ptex->size,value,mtex->sizefac,blend);
- if((event & mtex->pmapto) & MAP_PA_IVEL)
- ptex->ivel= texture_value_blend(def,ptex->ivel,value,mtex->ivelfac,blend);
- if((event & mtex->pmapto) & MAP_PA_PVEL)
- texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,mtex->pvelfac,blend);
- if((event & mtex->pmapto) & MAP_PA_LENGTH)
- ptex->length= texture_value_blend(def,ptex->length,value,mtex->lengthfac,blend);
- if((event & mtex->pmapto) & MAP_PA_CLUMP)
- ptex->clump= texture_value_blend(def,ptex->clump,value,mtex->clumpfac,blend);
- if((event & mtex->pmapto) & MAP_PA_KINK)
- ptex->kink= texture_value_blend(def,ptex->kink,value,mtex->kinkfac,blend);
- }
- }
- if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); }
- if(event & MAP_PA_LIFE) { CLAMP(ptex->life,0.0,1.0); }
- if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); }
- if(event & MAP_PA_SIZE) { CLAMP(ptex->size,0.0,1.0); }
- if(event & MAP_PA_IVEL) { CLAMP(ptex->ivel,0.0,1.0); }
- if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); }
- if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); }
- if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); }
+ SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac)
+ SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac)
+ SET_PARTICLE_TEXTURE(PAMAP_SIZE, ptex->size, mtex->sizefac)
+ SET_PARTICLE_TEXTURE(PAMAP_IVEL, ptex->ivel, mtex->ivelfac)
+ SET_PARTICLE_TEXTURE(PAMAP_FIELD, ptex->field, mtex->fieldfac)
+ SET_PARTICLE_TEXTURE(PAMAP_GRAVITY, ptex->gravity, mtex->gravityfac)
+ SET_PARTICLE_TEXTURE(PAMAP_DAMP, ptex->damp, mtex->dampfac)
+ SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac)
+ }
+ }
+
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_TIME, ptex->time)
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LIFE, ptex->life)
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist)
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_SIZE, ptex->size)
+ CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_IVEL, ptex->ivel)
+ CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_FIELD, ptex->field)
+ CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_GRAVITY, ptex->gravity)
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DAMP, ptex->damp)
+ CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length)
}
/************************************************/
/* Particle State */
@@ -3828,28 +3874,8 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED
ParticleSettings *part = psys->part;
float size; // time XXX
- if(part->childtype==PART_CHILD_FACES){
+ if(part->childtype==PART_CHILD_FACES)
size=part->size;
-
-#if 0 // XXX old animation system
- if((part->flag&PART_ABS_TIME)==0 && part->ipo){
- IpoCurve *icu;
-
- if(pa_time)
- time=*pa_time;
- else
- time=psys_get_child_time(psys,cpa,cfra,NULL,NULL);
-
- /* correction for lifetime */
- calc_ipo(part->ipo, 100*time);
-
- for(icu = part->ipo->curve.first; icu; icu=icu->next) {
- if(icu->adrcode == PART_SIZE)
- size = icu->curval;
- }
- }
-#endif // XXX old animation system
- }
else
size=psys->particles[cpa->parent].size;
@@ -3865,19 +3891,7 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread
ParticleSystem *psys = ctx->sim.psys;
int i = cpa - psys->child;
- ptex->length= 1.0f - part->randlength * PSYS_FRAND(i + 26);
- ptex->clump=1.0;
- ptex->kink=1.0;
- ptex->rough1= 1.0;
- ptex->rough2= 1.0;
- ptex->roughe= 1.0;
- ptex->exist= 1.0;
- ptex->effector= 1.0;
-
- ptex->length*= part->clength_thres < PSYS_FRAND(i + 27) ? part->clength : 1.0f;
-
- get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,ptex,
- MAP_PA_DENS|MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH);
+ get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS|PAMAP_CHILD, psys->cfra);
if(ptex->exist < PSYS_FRAND(i + 24))
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 4d3a908edb0..65bd4f110b4 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -120,7 +120,8 @@ static int particles_are_dynamic(ParticleSystem *psys) {
else
return ELEM3(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
}
-int psys_get_current_display_percentage(ParticleSystem *psys)
+
+static int psys_get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
@@ -173,7 +174,7 @@ void psys_reset(ParticleSystem *psys, int mode)
/* reset children */
if(psys->child) {
MEM_freeN(psys->child);
- psys->child= 0;
+ psys->child= NULL;
}
psys->totchild= 0;
@@ -277,7 +278,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart)
if(psys->child) {
MEM_freeN(psys->child);
- psys->child=0;
+ psys->child=NULL;
psys->totchild=0;
}
}
@@ -312,7 +313,7 @@ static void alloc_child_particles(ParticleSystem *psys, int tot)
}
MEM_freeN(psys->child);
- psys->child=0;
+ psys->child=NULL;
psys->totchild=0;
}
@@ -401,7 +402,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
{
- ParticleData *pa=0;
+ ParticleData *pa=NULL;
float min[3], max[3], delta[3], d;
MVert *mv, *mvert = dm->getVertDataArray(dm,0);
int totvert=dm->getNumVerts(dm), from=psys->part->from;
@@ -410,8 +411,8 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
mv=mvert;
/* find bounding box of dm */
- VECCOPY(min,mv->co);
- VECCOPY(max,mv->co);
+ copy_v3_v3(min, mv->co);
+ copy_v3_v3(max, mv->co);
mv++;
for(i=1; i<totvert; i++, mv++){
@@ -427,13 +428,13 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
VECSUB(delta,max,min);
/* determine major axis */
- axis = (delta[0]>=delta[1])?0:((delta[1]>=delta[2])?1:2);
-
+ axis = (delta[0]>=delta[1]) ? 0 : ((delta[1]>=delta[2]) ? 1 : 2);
+
d = delta[axis]/(float)res;
- size[axis]=res;
- size[(axis+1)%3]=(int)ceil(delta[(axis+1)%3]/d);
- size[(axis+2)%3]=(int)ceil(delta[(axis+2)%3]/d);
+ size[axis] = res;
+ size[(axis+1)%3] = (int)ceil(delta[(axis+1)%3]/d);
+ size[(axis+2)%3] = (int)ceil(delta[(axis+2)%3]/d);
/* float errors grrr.. */
size[(axis+1)%3] = MIN2(size[(axis+1)%3],res);
@@ -451,11 +452,11 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
for(i=0,p=0,pa=psys->particles; i<res; i++){
for(j=0; j<res; j++){
for(k=0; k<res; k++,p++,pa++){
- pa->fuv[0]=min[0]+(float)i*d;
- pa->fuv[1]=min[1]+(float)j*d;
- pa->fuv[2]=min[2]+(float)k*d;
+ pa->fuv[0] = min[0] + (float)i*d;
+ pa->fuv[1] = min[1] + (float)j*d;
+ pa->fuv[2] = min[2] + (float)k*d;
pa->flag |= PARS_UNEXIST;
- pa->hair_index=0; /* abused in volume calculation */
+ pa->hair_index = 0; /* abused in volume calculation */
}
}
}
@@ -466,9 +467,9 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
pa=psys->particles;
- min[0]-=d/2.0f;
- min[1]-=d/2.0f;
- min[2]-=d/2.0f;
+ min[0] -= d/2.0f;
+ min[1] -= d/2.0f;
+ min[2] -= d/2.0f;
for(i=0,mv=mvert; i<totvert; i++,mv++){
sub_v3_v3v3(vec,mv->co,min);
@@ -500,20 +501,20 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
for(a2=0; a2<size[(a+2)%3]; a2++){
mface= mface_array;
- pa=psys->particles + a1*a1mul + a2*a2mul;
- VECCOPY(co1,pa->fuv);
- co1[a]-= d < delta[a] ? d/2.f : delta[a]/2.f;
- VECCOPY(co2,co1);
- co2[a]+=delta[a] + 0.001f*d;
- co1[a]-=0.001f*d;
+ pa = psys->particles + a1*a1mul + a2*a2mul;
+ copy_v3_v3(co1, pa->fuv);
+ co1[a] -= d < delta[a] ? d/2.f : delta[a]/2.f;
+ copy_v3_v3(co2, co1);
+ co2[a] += delta[a] + 0.001f*d;
+ co1[a] -= 0.001f*d;
/* lets intersect the faces */
for(i=0; i<totface; i++,mface++){
- VECCOPY(v1,mvert[mface->v1].co);
- VECCOPY(v2,mvert[mface->v2].co);
- VECCOPY(v3,mvert[mface->v3].co);
+ copy_v3_v3(v1, mvert[mface->v1].co);
+ copy_v3_v3(v2, mvert[mface->v2].co);
+ copy_v3_v3(v3, mvert[mface->v3].co);
- if(isect_axial_line_tri_v3(a,co1, co2, v2, v3, v1, &lambda)){
+ if(isect_axial_line_tri_v3(a, co1, co2, v2, v3, v1, &lambda)){
if(from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else /* store number of intersections */
@@ -521,9 +522,9 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
}
if(mface->v4){
- VECCOPY(v4,mvert[mface->v4].co);
+ copy_v3_v3(v4, mvert[mface->v4].co);
- if(isect_axial_line_tri_v3(a,co1, co2, v4, v1, v3, &lambda)){
+ if(isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)){
if(from==PART_FROM_FACE)
(pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST;
else
@@ -548,6 +549,22 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys)
}
}
+ if(psys->part->flag & PART_GRID_HEXAGONAL) {
+ for(i=0,p=0,pa=psys->particles; i<res; i++){
+ for(j=0; j<res; j++){
+ for(k=0; k<res; k++,p++,pa++){
+ if(j%2)
+ pa->fuv[0] += d/2.f;
+
+ if(k%2) {
+ pa->fuv[0] += d/2.f;
+ pa->fuv[1] += d/2.f;
+ }
+ }
+ }
+ }
+ }
+
if(psys->part->flag & PART_GRID_INVERT){
for(i=0; i<size[0]; i++){
for(j=0; j<size[1]; j++){
@@ -1519,62 +1536,37 @@ void psys_threads_free(ParticleThread *threads)
/* set particle parameters that don't change during particle's life */
void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p)
{
- ParticleSettings *part = sim->psys->part;
+ ParticleSystem *psys = sim->psys;
+ ParticleSettings *part = psys->part;
ParticleTexture ptex;
- Material *ma=0;
- //IpoCurve *icu=0; // XXX old animation system
- int totpart;
-
- totpart=sim->psys->totpart;
-
- ptex.life=ptex.size=ptex.exist=ptex.length=1.0;
- ptex.time=(float)p/(float)totpart;
-
- BLI_srandom(sim->psys->seed + p + 125);
- if(part->from!=PART_FROM_PARTICLE && part->type!=PART_FLUID){
- ma=give_current_material(sim->ob,part->omat);
+ pa->flag &= ~PARS_UNEXIST;
- /* TODO: needs some work to make most blendtypes generally usefull */
- psys_get_texture(sim,ma,pa,&ptex,MAP_PA_INIT);
- }
-
- if(part->type==PART_HAIR)
- pa->time= 0.0f;
- //else if(part->type==PART_REACTOR && (part->flag&PART_REACT_STA_END)==0)
- // pa->time= 300000.0f; /* max frame */
- else{
- //icu=find_ipocurve(psys->part->ipo,PART_EMIT_TIME);
- //if(icu){
- // calc_icu(icu,100*ptex.time);
- // ptex.time=icu->curval;
- //}
-
- pa->time= part->sta + (part->end - part->sta)*ptex.time;
- }
-
- if(part->type!=PART_HAIR && part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){
- if(ptex.exist < BLI_frand())
+ if(part->from != PART_FROM_PARTICLE && part->type != PART_FLUID) {
+ psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
+
+ if(ptex.exist < PSYS_FRAND(p+125))
pa->flag |= PARS_UNEXIST;
- else
- pa->flag &= ~PARS_UNEXIST;
+
+ pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time;
}
- pa->hair_index=0;
+ pa->hair_index = 0;
/* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */
/* usage other than straight after distribute has to handle this index by itself - jahka*/
//pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we dont have a derived mesh face */
}
static void initialize_all_particles(ParticleSimulationData *sim)
{
- //IpoCurve *icu=0; // XXX old animation system
ParticleSystem *psys = sim->psys;
PARTICLE_P;
psys->totunexist = 0;
LOOP_PARTICLES {
- initialize_particle(sim, pa, p);
+ if((pa->flag & PARS_UNEXIST)==0)
+ initialize_particle(sim, pa, p);
+
if(pa->flag & PARS_UNEXIST)
psys->totunexist++;
}
@@ -1616,60 +1608,6 @@ static void initialize_all_particles(ParticleSimulationData *sim)
}
}
-
- if(psys->part->type != PART_FLUID) {
-#if 0 // XXX old animation system
- icu=find_ipocurve(psys->part->ipo,PART_EMIT_FREQ);
- if(icu){
- float time=psys->part->sta, end=psys->part->end;
- float v1, v2, a=0.0f, t1,t2, d;
-
- p=0;
- pa=psys->particles;
-
-
- calc_icu(icu,time);
- v1=icu->curval;
- if(v1<0.0f) v1=0.0f;
-
- calc_icu(icu,time+1.0f);
- v2=icu->curval;
- if(v2<0.0f) v2=0.0f;
-
- for(p=0, pa=psys->particles; p<totpart && time<end; p++, pa++){
- while(a+0.5f*(v1+v2) < (float)(p+1) && time<end){
- a+=0.5f*(v1+v2);
- v1=v2;
- time++;
- calc_icu(icu,time+1.0f);
- v2=icu->curval;
- }
- if(time<end){
- if(v1==v2){
- pa->time=time+((float)(p+1)-a)/v1;
- }
- else{
- d=(float)sqrt(v1*v1-2.0f*(v2-v1)*(a-(float)(p+1)));
- t1=(-v1+d)/(v2-v1);
- t2=(-v1-d)/(v2-v1);
-
- /* the root between 0-1 is the correct one */
- if(t1>0.0f && t1<=1.0f)
- pa->time=time+t1;
- else
- pa->time=time+t2;
- }
- }
-
- pa->dietime = pa->time+pa->lifetime;
- pa->flag &= ~PARS_UNEXIST;
- }
- for(; p<totpart; p++, pa++){
- pa->flag |= PARS_UNEXIST;
- }
- }
-#endif // XXX old animation system
- }
}
/* sets particle to the emitter surface with initial velocity & rotation */
void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra)
@@ -1678,35 +1616,14 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
ParticleSystem *psys = sim->psys;
ParticleSettings *part;
ParticleTexture ptex;
- ParticleKey state;
- //IpoCurve *icu=0; // XXX old animation system
float fac, phasefac, nor[3]={0,0,0},loc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4];
float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3]={0.0,0.0,0.0};
float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0};
- float q_phase[4], r_phase;
+ float q_phase[4];
int p = pa - psys->particles;
part=psys->part;
-
- ptex.ivel=1.0;
- ptex.life=1.0;
-
- /* we need to get every random even if they're not used so that they don't effect eachother */
- 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);
-
- r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f);
- r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f);
- r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f);
-
- r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f);
- r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f);
- r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f);
- r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f);
- normalize_qt(r_rot);
-
- r_phase = PSYS_FRAND(p + 20);
+#if 0 /* deprecated code */
if(part->from==PART_FROM_PARTICLE){
float speed;
ParticleSimulationData tsim= {0};
@@ -1733,79 +1650,93 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
VECCOPY(pa->fuv, loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */
}
else{
- /* get precise emitter matrix if particle is born */
- if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) {
- /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
- BKE_animsys_evaluate_animdata(&sim->ob->id, sim->ob->adt, pa->time, ADT_RECALC_ANIM);
- where_is_object_time(sim->scene, sim->ob, pa->time);
- }
+#endif
+ /* get precise emitter matrix if particle is born */
+ if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) {
+ /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */
+ BKE_animsys_evaluate_animdata(&sim->ob->id, sim->ob->adt, pa->time, ADT_RECALC_ANIM);
+ where_is_object_time(sim->scene, sim->ob, pa->time);
+ }
- /* get birth location from object */
- if(part->tanfac!=0.0)
- psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
- else
- psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0);
+ /* get birth location from object */
+ if(part->tanfac != 0.f)
+ psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0);
+ else
+ 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, give_current_material(sim->ob,part->omat), pa, &ptex, MAP_PA_IVEL|MAP_PA_LIFE);
+ /* get possible textural influence */
+ psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra);
- //if(vg_vel && pa->num != -1)
- // ptex.ivel*=psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_vel);
-
- /* particles live in global space so */
- /* let's convert: */
- /* -location */
- mul_m4_v3(ob->obmat,loc);
+ /* particles live in global space so */
+ /* let's convert: */
+ /* -location */
+ mul_m4_v3(ob->obmat, loc);
- /* -normal */
- mul_mat3_m4_v3(ob->obmat,nor);
- normalize_v3(nor);
-
- /* -tangent */
- if(part->tanfac!=0.0){
- //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
- float phase=0.0f;
- mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase)));
- fac=-(float)sin(M_PI*(part->tanphase+phase));
- VECADDFAC(vtan,vtan,utan,fac);
-
- mul_mat3_m4_v3(ob->obmat,vtan);
-
- VECCOPY(utan,nor);
- mul_v3_fl(utan,dot_v3v3(vtan,nor));
- VECSUB(vtan,vtan,utan);
+ /* -normal */
+ mul_mat3_m4_v3(ob->obmat, nor);
+ normalize_v3(nor);
+
+ /* -tangent */
+ if(part->tanfac!=0.0){
+ //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f;
+ float phase=0.0f;
+ mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase)));
+ fac=-(float)sin(M_PI*(part->tanphase+phase));
+ VECADDFAC(vtan,vtan,utan,fac);
+
+ mul_mat3_m4_v3(ob->obmat,vtan);
+
+ VECCOPY(utan,nor);
+ mul_v3_fl(utan,dot_v3v3(vtan,nor));
+ VECSUB(vtan,vtan,utan);
- normalize_v3(vtan);
- }
+ normalize_v3(vtan);
+ }
- /* -velocity */
- if(part->randfac!=0.0){
- mul_mat3_m4_v3(ob->obmat,r_vel);
- normalize_v3(r_vel);
- }
+ /* -velocity */
+ if(part->randfac!=0.0){
+ 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);
- /* -angular velocity */
- if(part->avemode==PART_AVE_RAND){
- mul_mat3_m4_v3(ob->obmat,r_ave);
- normalize_v3(r_ave);
- }
+ mul_mat3_m4_v3(ob->obmat, r_vel);
+ normalize_v3(r_vel);
+ }
+
+ /* -angular velocity */
+ if(part->avemode==PART_AVE_RAND){
+ r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f);
+ r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f);
+ r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f);
+
+ mul_mat3_m4_v3(ob->obmat,r_ave);
+ normalize_v3(r_ave);
+ }
- /* -rotation */
- if(part->randrotfac != 0.0f){
- mat4_to_quat(rot,ob->obmat);
- mul_qt_qtqt(r_rot,r_rot,rot);
- }
+ /* -rotation */
+ if(part->randrotfac != 0.0f){
+ r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f);
+ r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f);
+ r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f);
+ r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f);
+ normalize_qt(r_rot);
+
+ 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];
- VECCOPY(pa->state.co,loc);
+ copy_v3_v3(pa->state.co,loc);
/* boids don't get any initial velocity */
- pa->state.vel[0]=pa->state.vel[1]=pa->state.vel[2]=0.0f;
+ zero_v3(pa->state.vel);
/* boids store direction in ave */
if(fabs(nor[2])==1.0f) {
@@ -1844,66 +1775,56 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* -velocity from: */
/* *reactions */
- if(dtime>0.0f){
- VECSUB(vel,pa->state.vel,pa->prev_state.vel);
+ if(dtime > 0.f){
+ sub_v3_v3v3(vel, pa->state.vel, pa->prev_state.vel);
}
/* *emitter velocity */
- if(dtime!=0.0 && part->obfac!=0.0){
- VECSUB(vel,loc,pa->state.co);
- mul_v3_fl(vel,part->obfac/dtime);
+ if(dtime != 0.f && part->obfac != 0.f){
+ sub_v3_v3v3(vel, loc, pa->state.co);
+ mul_v3_fl(vel, part->obfac/dtime);
}
/* *emitter normal */
- if(part->normfac!=0.0)
- VECADDFAC(vel,vel,nor,part->normfac);
+ if(part->normfac != 0.f)
+ madd_v3_v3fl(vel, nor, part->normfac);
/* *emitter tangent */
- if(sim->psmd && part->tanfac!=0.0)
- VECADDFAC(vel,vel,vtan,part->tanfac);
- //VECADDFAC(vel,vel,vtan,part->tanfac*(vg_tan?psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_tan):1.0f));
+ if(sim->psmd && part->tanfac != 0.f)
+ madd_v3_v3fl(vel, vtan, part->tanfac);
/* *emitter object orientation */
- if(part->ob_vel[0]!=0.0) {
+ if(part->ob_vel[0] != 0.f) {
normalize_v3_v3(vec, ob->obmat[0]);
- VECADDFAC(vel, vel, vec, part->ob_vel[0]);
+ madd_v3_v3fl(vel, vec, part->ob_vel[0]);
}
- if(part->ob_vel[1]!=0.0) {
+ if(part->ob_vel[1] != 0.f) {
normalize_v3_v3(vec, ob->obmat[1]);
- VECADDFAC(vel, vel, vec, part->ob_vel[1]);
+ madd_v3_v3fl(vel, vec, part->ob_vel[1]);
}
- if(part->ob_vel[2]!=0.0) {
+ if(part->ob_vel[2] != 0.f) {
normalize_v3_v3(vec, ob->obmat[2]);
- VECADDFAC(vel, vel, vec, part->ob_vel[2]);
+ madd_v3_v3fl(vel, vec, part->ob_vel[2]);
}
/* *texture */
/* TODO */
/* *random */
- if(part->randfac!=0.0)
- VECADDFAC(vel,vel,r_vel,part->randfac);
+ if(part->randfac != 0.f)
+ madd_v3_v3fl(vel, r_vel, part->randfac);
/* *particle */
- if(part->partfac!=0.0)
- VECADDFAC(vel,vel,p_vel,part->partfac);
-
- //icu=find_ipocurve(psys->part->ipo,PART_EMIT_VEL);
- //if(icu){
- // calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta)));
- // ptex.ivel*=icu->curval;
- //}
-
- mul_v3_fl(vel,ptex.ivel);
+ if(part->partfac != 0.f)
+ madd_v3_v3fl(vel, p_vel, part->partfac);
- VECCOPY(pa->state.vel,vel);
+ mul_v3_v3fl(pa->state.vel, vel, ptex.ivel);
/* -location from emitter */
- VECCOPY(pa->state.co,loc);
+ copy_v3_v3(pa->state.co,loc);
/* -rotation */
- pa->state.rot[0]=1.0;
- pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0.0;
+ unit_qt(pa->state.rot);
if(part->rotmode){
/* create vector into which rotation is aligned */
@@ -1939,7 +1860,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* rotation phase */
phasefac = part->phasefac;
if(part->randphasefac != 0.0f)
- phasefac += part->randphasefac * r_phase;
+ phasefac += part->randphasefac * PSYS_FRAND(p + 20);
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
/* combine base rotation & phase */
@@ -1948,25 +1869,19 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* -angular velocity */
- pa->state.ave[0] = pa->state.ave[1] = pa->state.ave[2] = 0.0;
+ zero_v3(pa->state.ave);
if(part->avemode){
switch(part->avemode){
case PART_AVE_SPIN:
- VECCOPY(pa->state.ave,vel);
+ copy_v3_v3(pa->state.ave, vel);
break;
case PART_AVE_RAND:
- VECCOPY(pa->state.ave,r_ave);
+ copy_v3_v3(pa->state.ave, r_ave);
break;
}
normalize_v3(pa->state.ave);
mul_v3_fl(pa->state.ave,part->avefac);
-
- //icu=find_ipocurve(psys->part->ipo,PART_EMIT_AVE);
- //if(icu){
- // calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta)));
- // mul_v3_fl(pa->state.ave,icu->curval);
- //}
}
}
@@ -1975,7 +1890,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->lifetime = 100.0f;
}
else{
- pa->lifetime = part->lifetime*ptex.life;
+ pa->lifetime = part->lifetime * ptex.life;
if(part->randlife != 0.0)
pa->lifetime *= 1.0f - part->randlife * PSYS_FRAND(p + 21);
@@ -2002,15 +1917,9 @@ static void reset_all_particles(ParticleSimulationData *sim, float dtime, float
{
ParticleData *pa;
int p, totpart=sim->psys->totpart;
- //float *vg_vel=psys_cache_vgroup(sim->psmd->dm,sim->psys,PSYS_VG_VEL);
- //float *vg_tan=psys_cache_vgroup(sim->psmd->dm,sim->psys,PSYS_VG_TAN);
- //float *vg_rot=psys_cache_vgroup(sim->psmd->dm,sim->psys,PSYS_VG_ROT);
for(p=from, pa=sim->psys->particles+from; p<totpart; p++, pa++)
reset_particle(sim, pa, dtime, cfra);
-
- //if(vg_vel)
- // MEM_freeN(vg_vel);
}
/************************************************/
/* Particle targets */
@@ -2542,6 +2451,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
float force[3],impulse[3],dx[4][3],dv[4][3],oldpos[3];
float dtime=dfra*timestep, time, pa_mass=part->mass, fac /*, fra=sim->psys->cfra*/;
int i, steps=1;
+ ParticleTexture ptex;
+
+ psys_get_texture(sim, pa, &ptex, PAMAP_PHYSICS, cfra);
/* maintain angular velocity */
VECCOPY(pa->state.ave,pa->prev_state.ave);
@@ -2575,6 +2487,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
if(part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)
pdDoEffectors(sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse);
+ mul_v3_fl(force, ptex.field);
+ mul_v3_fl(impulse, ptex.field);
+
/* calculate air-particle interaction */
if(part->dragfac!=0.0f){
fac=-part->dragfac*pa->size*pa->size*len_v3(states[i].vel);
@@ -2595,10 +2510,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
if(psys_uses_gravity(sim)
/* normal gravity is too strong for hair so it's disabled by default */
&& (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) {
- float gravity[3];
- VECCOPY(gravity, sim->scene->physics_settings.gravity);
- mul_v3_fl(gravity, part->effector_weights->global_gravity);
- VECADD(force,force,gravity);
+ madd_v3_v3fl(force, sim->scene->physics_settings.gravity, part->effector_weights->global_gravity * ptex.gravity);
}
/* calculate next state */
@@ -2679,8 +2591,8 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra
}
/* damp affects final velocity */
- if(part->dampfac!=0.0)
- mul_v3_fl(pa->state.vel,1.0f-part->dampfac);
+ if(part->dampfac != 0.f)
+ mul_v3_fl(pa->state.vel, 1.f - part->dampfac * ptex.damp);
VECCOPY(pa->state.ave, states->ave);
@@ -3471,6 +3383,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
ParticleSystem *psys = sim->psys;
ParticleSettings *part=psys->part;
BoidBrainData bbd;
+ ParticleTexture ptex;
PARTICLE_P;
float timestep;
/* frame & time changes */
@@ -3485,7 +3398,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
if(dfra<0.0){
LOOP_EXISTING_PARTICLES {
- pa->size = part->size;
+ psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
+ pa->size = part->size*ptex.size;
if(part->randsize > 0.0)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
@@ -3538,7 +3452,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
LOOP_SHOWN_PARTICLES {
copy_particle_key(&pa->prev_state,&pa->state,1);
- pa->size = part->size;
+ psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
+
+ pa->size = part->size*ptex.size;
if(part->randsize > 0.0)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
@@ -3685,6 +3601,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
+ ParticleTexture ptex;
PARTICLE_P;
float disp, dietime;
@@ -3695,7 +3612,8 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
disp= (float)psys_get_current_display_percentage(psys)/100.0f;
LOOP_PARTICLES {
- pa->size = part->size;
+ psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
+ pa->size = part->size*ptex.size;
if(part->randsize > 0.0)
pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
@@ -3744,8 +3662,6 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
FluidsimSettings *fss= fluidmd->fss;
ParticleSettings *part = psys->part;
ParticleData *pa=NULL;
- const char *suffix = "fluidsurface_particles_####";
- const char *suffix2 = ".gz";
char filename[256];
char debugStrBuffer[256];
int curFrame = sim->scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading
@@ -3755,14 +3671,13 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
// XXX if(ob==G.obedit) // off...
// return;
-
+
// ok, start loading
- strcpy(filename, fss->surfdataPath);
- strcat(filename, suffix);
+ BLI_snprintf(filename, sizeof(filename), "%sfluidsurface_particles_####.gz", fss->surfdataPath);
+
BLI_path_abs(filename, G.main->name);
BLI_path_frame(filename, curFrame, 0); // fixed #frame-no
- strcat(filename, suffix2);
-
+
gzf = gzopen(filename, "rb");
if (!gzf) {
snprintf(debugStrBuffer,256,"readFsPartData::error - Unable to open file for reading '%s' \n", filename);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 65bf055886e..c2ec463c708 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1992,7 +1992,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */
if (mode == PTCACHE_CLEAR_ALL) {
pid->cache->last_exact = MIN2(pid->cache->startframe, 0);
- BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, 0, 0);
} else {
/* read the number of the file */
@@ -2006,7 +2006,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) ||
(mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) {
- BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, 0, 0);
if(pid->cache->cached_frames && frame >=sta && frame <= end)
pid->cache->cached_frames[frame-sta] = 0;
@@ -2354,7 +2354,7 @@ void BKE_ptcache_remove(void)
if( strcmp(de->d_name, ".")==0 || strcmp(de->d_name, "..")==0) {
/* do nothing */
} else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/
- BLI_join_dirfile(path_full, path, de->d_name);
+ BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name);
BLI_delete(path_full, 0, 0);
} else {
rmdir = 0; /* unknown file, dont remove the dir */
@@ -2390,7 +2390,7 @@ void BKE_ptcache_set_continue_physics(Main *bmain, Scene *scene, int enable)
}
}
-int BKE_ptcache_get_continue_physics()
+int BKE_ptcache_get_continue_physics(void)
{
return CONTINUE_PHYSICS;
}
@@ -2856,13 +2856,14 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to)
BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num));
frame = atoi(num);
- BLI_join_dirfile(old_path_full, path, de->d_name);
+ BLI_join_dirfile(old_path_full, sizeof(old_path_full), path, de->d_name);
ptcache_filename(pid, new_path_full, frame, 1, 1);
BLI_rename(old_path_full, new_path_full);
}
}
}
}
+ closedir(dir);
strcpy(pid->cache->name, old_name);
}
@@ -2929,8 +2930,10 @@ void BKE_ptcache_load_external(PTCacheID *pid)
cache->endframe = end;
cache->totpoint = 0;
+ if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN)
+ ; /*necessary info in every file*/
/* read totpoint from info file (frame 0) */
- if(info) {
+ else if(info) {
pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0);
if(pf) {
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index dd57fef50c5..e907b628242 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -43,6 +43,8 @@
#include "BLI_blenlib.h"
+#include "BKE_property.h"
+
void free_property(bProperty *prop)
{
@@ -93,7 +95,7 @@ void init_property(bProperty *prop)
/* also use when property changes type */
if(prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin);
- prop->poin= 0;
+ prop->poin= NULL;
prop->data= 0;
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 12f82d041f9..c8ef834fbbb 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -86,7 +86,7 @@ void copy_sensors(ListBase *lbn, ListBase *lbo)
{
bSensor *sens, *sensn;
- lbn->first= lbn->last= 0;
+ lbn->first= lbn->last= NULL;
sens= lbo->first;
while(sens) {
sensn= copy_sensor(sens);
@@ -253,7 +253,7 @@ void copy_controllers(ListBase *lbn, ListBase *lbo)
{
bController *cont, *contn;
- lbn->first= lbn->last= 0;
+ lbn->first= lbn->last= NULL;
cont= lbo->first;
while(cont) {
contn= copy_controller(cont);
@@ -267,7 +267,7 @@ void init_controller(bController *cont)
/* also use when controller changes type, leave actuators... */
if(cont->data) MEM_freeN(cont->data);
- cont->data= 0;
+ cont->data= NULL;
switch(cont->type) {
case CONT_EXPRESSION:
@@ -375,7 +375,7 @@ void copy_actuators(ListBase *lbn, ListBase *lbo)
{
bActuator *act, *actn;
- lbn->first= lbn->last= 0;
+ lbn->first= lbn->last= NULL;
act= lbo->first;
while(act) {
actn= copy_actuator(act);
@@ -393,7 +393,7 @@ void init_actuator(bActuator *act)
bSoundActuator *sa;
if(act->data) MEM_freeN(act->data);
- act->data= 0;
+ act->data= NULL;
switch(act->type) {
case ACT_ACTION:
@@ -512,7 +512,7 @@ void clear_sca_new_poins_ob(Object *ob)
}
}
-void clear_sca_new_poins()
+void clear_sca_new_poins(void)
{
Object *ob;
@@ -595,7 +595,7 @@ void set_sca_new_poins_ob(Object *ob)
}
-void set_sca_new_poins()
+void set_sca_new_poins(void)
{
Object *ob;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 3c58b97a0c0..84869fde206 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -173,7 +173,7 @@ Scene *copy_scene(Scene *sce, int type)
BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets));
if(sce->nodetree) {
- scen->nodetree= ntreeCopyTree(sce->nodetree, 0); /* copies actions */
+ scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */
ntreeSwitchID(scen->nodetree, &sce->id, &scen->id);
}
@@ -588,7 +588,7 @@ void set_scene_bg(Main *bmain, Scene *scene)
}
/* called from creator.c */
-Scene *set_scene_name(Main *bmain, char *name)
+Scene *set_scene_name(Main *bmain, const char *name)
{
Scene *sce= (Scene *)find_id("SC", name);
if(sce) {
@@ -952,27 +952,68 @@ float BKE_curframe(Scene *scene)
return ctime;
}
+/* drivers support/hacks
+ * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render
+ * - these are always run since the depsgraph can't handle non-object data
+ * - these happen after objects are all done so that we can read in their final transform values,
+ * though this means that objects can't refer to scene info for guidance...
+ */
+static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene)
+{
+ float ctime = BKE_curframe(scene);
+
+ /* scene itself */
+ if (scene->adt && scene->adt->drivers.first) {
+ BKE_animsys_evaluate_animdata(&scene->id, scene->adt, ctime, ADT_RECALC_DRIVERS);
+ }
+
+ /* world */
+ // TODO: what about world textures? but then those have nodes too...
+ if (scene->world) {
+ ID *wid = (ID *)scene->world;
+ AnimData *adt= BKE_animdata_from_id(wid);
+
+ if (adt && adt->drivers.first)
+ BKE_animsys_evaluate_animdata(wid, adt, ctime, ADT_RECALC_DRIVERS);
+ }
+
+ /* nodes */
+ if (scene->nodetree) {
+ ID *nid = (ID *)scene->nodetree;
+ AnimData *adt= BKE_animdata_from_id(nid);
+
+ if (adt && adt->drivers.first)
+ BKE_animsys_evaluate_animdata(nid, adt, ctime, ADT_RECALC_DRIVERS);
+ }
+}
+
static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent)
{
Base *base;
+
+
scene->customdata_mask= scene_parent->customdata_mask;
/* sets first, we allow per definition current scene to have
dependencies on sets, but not the other way around. */
- if(scene->set)
+ if (scene->set)
scene_update_tagged_recursive(bmain, scene->set, scene_parent);
-
- for(base= scene->base.first; base; base= base->next) {
+
+ /* scene objects */
+ for (base= scene->base.first; base; base= base->next) {
Object *ob= base->object;
-
+
object_handle_update(scene_parent, ob);
-
+
if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP))
group_handle_recalc_and_update(scene_parent, ob, ob->dup_group);
/* always update layer, so that animating layers works */
base->lay= ob->lay;
}
+
+ /* scene drivers... */
+ scene_update_drivers(bmain, scene);
}
/* this is called in main loop, doing tagged updates before redraw */
@@ -989,14 +1030,14 @@ void scene_update_tagged(Main *bmain, Scene *scene)
/* recalc scene animation data here (for sequencer) */
{
- float ctime = BKE_curframe(scene);
AnimData *adt= BKE_animdata_from_id(&scene->id);
-
- if(adt && (adt->recalc & ADT_RECALC_ANIM))
+ float ctime = BKE_curframe(scene);
+
+ if (adt && (adt->recalc & ADT_RECALC_ANIM))
BKE_animsys_evaluate_animdata(&scene->id, adt, ctime, 0);
}
-
- if(scene->physics_settings.quick_cache_step)
+
+ if (scene->physics_settings.quick_cache_step)
BKE_ptcache_quick_cache_all(bmain, scene);
/* in the future this should handle updates for all datablocks, not
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 6f1d32898f9..58900e603e3 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -109,7 +109,7 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid)
}
-const ListBase *BKE_spacetypes_list()
+const ListBase *BKE_spacetypes_list(void)
{
return &spacetypes;
}
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index 78cd4bb51fe..1c40ef020be 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -54,10 +54,10 @@ typedef struct seqCacheEntry
MEM_CacheLimiterHandleC * c_handle;
} seqCacheEntry;
-static GHash * hash = 0;
-static MEM_CacheLimiterC * limitor = 0;
-static struct BLI_mempool * entrypool = 0;
-static struct BLI_mempool * keypool = 0;
+static GHash * hash = NULL;
+static MEM_CacheLimiterC * limitor = NULL;
+static struct BLI_mempool * entrypool = NULL;
+static struct BLI_mempool * keypool = NULL;
static int ibufs_in = 0;
static int ibufs_rem = 0;
@@ -119,8 +119,8 @@ static void HashValFree(void *val)
ibufs_rem++;
}
- e->ibuf = 0;
- e->c_handle = 0;
+ e->ibuf = NULL;
+ e->c_handle = NULL;
BLI_mempool_free(entrypool, e);
}
@@ -135,12 +135,12 @@ static void IMB_seq_cache_destructor(void * p)
IMB_freeImBuf(e->ibuf);
ibufs_rem++;
- e->ibuf = 0;
- e->c_handle = 0;
+ e->ibuf = NULL;
+ e->c_handle = NULL;
}
}
-void seq_stripelem_cache_init()
+void seq_stripelem_cache_init(void)
{
hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash");
limitor = new_MEM_CacheLimiter( IMB_seq_cache_destructor );
@@ -149,7 +149,7 @@ void seq_stripelem_cache_init()
keypool = BLI_mempool_create(sizeof(seqCacheKey), 64, 64, 0);
}
-void seq_stripelem_cache_destruct()
+void seq_stripelem_cache_destruct(void)
{
if (!entrypool) {
return;
@@ -160,7 +160,7 @@ void seq_stripelem_cache_destruct()
BLI_mempool_destroy(keypool);
}
-void seq_stripelem_cache_cleanup()
+void seq_stripelem_cache_cleanup(void)
{
if (!entrypool) {
seq_stripelem_cache_init();
@@ -185,7 +185,7 @@ struct ImBuf * seq_stripelem_cache_get(
seqCacheEntry * e;
if (!seq) {
- return 0;
+ return NULL;
}
if (!entrypool) {
@@ -205,7 +205,7 @@ struct ImBuf * seq_stripelem_cache_get(
MEM_CacheLimiter_touch(e->c_handle);
return e->ibuf;
}
- return 0;
+ return NULL;
}
void seq_stripelem_cache_put(
@@ -239,7 +239,7 @@ void seq_stripelem_cache_put(
e = (seqCacheEntry*) BLI_mempool_alloc(entrypool);
e->ibuf = i;
- e->c_handle = 0;
+ e->c_handle = NULL;
BLI_ghash_remove(hash, key, HashKeyFree, HashValFree);
BLI_ghash_insert(hash, key, e);
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 11075fe402e..da90ce4a715 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -125,12 +125,12 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
char *cp;
/* to be sure: (is tested for) */
- pis->doit= 0;
- pis->pname= 0;
- pis->varstr= 0;
- pis->cfra= 0;
+ pis->doit= NULL;
+ pis->pname= NULL;
+ pis->varstr= NULL;
+ pis->cfra= NULL;
pis->version= 0;
- pis->instance_private_data = 0;
+ pis->instance_private_data = NULL;
/* clear the error list */
PIL_dynlib_get_error_as_string(NULL);
@@ -142,12 +142,12 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
pis->handle= PIL_dynlib_open(pis->name);
if(test_dlerr(pis->name, pis->name)) return;
- if (pis->handle != 0) {
+ if (pis->handle != NULL) {
/* find the address of the version function */
version= (int (*)(void))PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion");
if (test_dlerr(pis->name, "plugin_seq_getversion")) return;
- if (version != 0) {
+ if (version != NULL) {
pis->version= version();
if (pis->version >= 2 && pis->version <= 6) {
int (*info_func)(PluginInfo *);
@@ -201,11 +201,11 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
strncpy(pis->name, str, FILE_MAXDIR+FILE_MAXFILE);
open_plugin_seq(pis, seqname);
- if(pis->doit==0) {
- if(pis->handle==0) error("no plugin: %s", str);
+ if(pis->doit==NULL) {
+ if(pis->handle==NULL) error("no plugin: %s", str);
else error("in plugin: %s", str);
MEM_freeN(pis);
- return 0;
+ return NULL;
}
/* default values */
@@ -222,7 +222,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
static void free_plugin_seq(PluginSeq *pis)
{
- if(pis==0) return;
+ if(pis==NULL) return;
/* no PIL_dynlib_close: same plugin can be opened multiple times with 1 handle */
@@ -270,7 +270,7 @@ static void copy_plugin(Sequence * dst, Sequence * src)
static ImBuf * IMB_cast_away_list(ImBuf * i)
{
if (!i) {
- return 0;
+ return NULL;
}
return (ImBuf*) (((void**) i) + 2);
}
@@ -383,7 +383,7 @@ static int do_plugin_early_out(struct Sequence *UNUSED(seq),
static void free_plugin(struct Sequence * seq)
{
free_plugin_seq(seq->plugin);
- seq->plugin = 0;
+ seq->plugin = NULL;
}
/* **********************************************************************
@@ -554,7 +554,7 @@ static struct ImBuf * do_alphaover_effect(
ALPHA UNDER
********************************************************************** */
-void do_alphaunder_effect_byte(
+static void do_alphaunder_effect_byte(
float facf0, float facf1, int x, int y, char *rect1,
char *rect2, char *out)
{
@@ -726,7 +726,7 @@ static struct ImBuf* do_alphaunder_effect(
CROSS
********************************************************************** */
-void do_cross_effect_byte(float facf0, float facf1, int x, int y,
+static void do_cross_effect_byte(float facf0, float facf1, int x, int y,
char *rect1, char *rect2,
char *out)
{
@@ -774,7 +774,7 @@ void do_cross_effect_byte(float facf0, float facf1, int x, int y,
}
}
-void do_cross_effect_float(float facf0, float facf1, int x, int y,
+static void do_cross_effect_float(float facf0, float facf1, int x, int y,
float *rect1, float *rect2, float *out)
{
float fac1, fac2, fac3, fac4;
@@ -1864,7 +1864,7 @@ static int num_inputs_wipe(void)
static void free_wipe_effect(Sequence *seq)
{
if(seq->effectdata)MEM_freeN(seq->effectdata);
- seq->effectdata = 0;
+ seq->effectdata = NULL;
}
static void copy_wipe_effect(Sequence *dst, Sequence *src)
@@ -2048,7 +2048,7 @@ static int num_inputs_transform(void)
static void free_transform_effect(Sequence *seq)
{
if(seq->effectdata)MEM_freeN(seq->effectdata);
- seq->effectdata = 0;
+ seq->effectdata = NULL;
}
static void copy_transform_effect(Sequence *dst, Sequence *src)
@@ -2617,7 +2617,7 @@ static int num_inputs_glow(void)
static void free_glow_effect(Sequence *seq)
{
if(seq->effectdata)MEM_freeN(seq->effectdata);
- seq->effectdata = 0;
+ seq->effectdata = NULL;
}
static void copy_glow_effect(Sequence *dst, Sequence *src)
@@ -2704,7 +2704,7 @@ static int num_inputs_color(void)
static void free_solid_color(Sequence *seq)
{
if(seq->effectdata)MEM_freeN(seq->effectdata);
- seq->effectdata = 0;
+ seq->effectdata = NULL;
}
static void copy_solid_color(Sequence *dst, Sequence *src)
@@ -2827,21 +2827,21 @@ static struct ImBuf * do_multicam(
ListBase * seqbasep;
if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) {
- return 0;
+ return NULL;
}
ed = context.scene->ed;
if (!ed) {
- return 0;
+ return NULL;
}
seqbasep = seq_seqbase(&ed->seqbase, seq);
if (!seqbasep) {
- return 0;
+ return NULL;
}
i = give_ibuf_seqbase(context, cfra, seq->multicam_source, seqbasep);
if (!i) {
- return 0;
+ return NULL;
}
if (input_have_to_preprocess(context, seq, cfra)) {
@@ -2867,7 +2867,7 @@ static void init_speed_effect(Sequence *seq)
v = (SpeedControlVars *)seq->effectdata;
v->globalSpeed = 1.0;
- v->frameMap = 0;
+ v->frameMap = NULL;
v->flags |= SEQ_SPEED_INTEGRATE; /* should be default behavior */
v->length = 0;
}
@@ -2876,7 +2876,7 @@ static void load_speed_effect(Sequence * seq)
{
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
- v->frameMap = 0;
+ v->frameMap = NULL;
v->length = 0;
}
@@ -2890,7 +2890,7 @@ static void free_speed_effect(Sequence *seq)
SpeedControlVars * v = (SpeedControlVars *)seq->effectdata;
if(v->frameMap) MEM_freeN(v->frameMap);
if(seq->effectdata) MEM_freeN(seq->effectdata);
- seq->effectdata = 0;
+ seq->effectdata = NULL;
}
static void copy_speed_effect(Sequence *dst, Sequence *src)
@@ -2898,7 +2898,7 @@ static void copy_speed_effect(Sequence *dst, Sequence *src)
SpeedControlVars * v;
dst->effectdata = MEM_dupallocN(src->effectdata);
v = (SpeedControlVars *)dst->effectdata;
- v->frameMap = 0;
+ v->frameMap = NULL;
v->length = 0;
}
@@ -3260,7 +3260,7 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type)
struct SeqEffectHandle get_sequence_effect(Sequence * seq)
{
- struct SeqEffectHandle rval= {0};
+ struct SeqEffectHandle rval= {NULL};
if (seq->type & SEQ_EFFECT) {
rval = get_sequence_effect_impl(seq->type);
@@ -3275,7 +3275,7 @@ struct SeqEffectHandle get_sequence_effect(Sequence * seq)
struct SeqEffectHandle get_sequence_blend(Sequence * seq)
{
- struct SeqEffectHandle rval= {0};
+ struct SeqEffectHandle rval= {NULL};
if (seq->blend_mode != 0) {
rval = get_sequence_effect_impl(seq->blend_mode);
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 6aca23b8011..9537931faec 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -135,7 +135,7 @@ static void free_proxy_seq(Sequence *seq)
{
if (seq->strip && seq->strip->proxy && seq->strip->proxy->anim) {
IMB_free_anim(seq->strip->proxy->anim);
- seq->strip->proxy->anim = 0;
+ seq->strip->proxy->anim = NULL;
}
}
@@ -429,7 +429,7 @@ void seq_end(SeqIterator *iter)
* in metastrips!)
**********************************************************************
*/
-
+#if 0 /* UNUSED */
static void do_seq_count(ListBase *seqbase, int *totseq)
{
Sequence *seq;
@@ -456,7 +456,7 @@ static void do_build_seqar(ListBase *seqbase, Sequence ***seqar, int depth)
}
}
-void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq)
+static void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq)
{
Sequence **tseqar;
@@ -473,6 +473,7 @@ void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq)
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))
@@ -664,7 +665,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range)
new_tstripdata(seq);
if (ELEM3(seq->type, SEQ_SCENE, SEQ_META, SEQ_IMAGE)==0) {
- BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
+ BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(str, G.main->name);
}
@@ -762,8 +763,8 @@ void sort_seq(Scene *scene)
if(ed==NULL) return;
- seqbase.first= seqbase.last= 0;
- effbase.first= effbase.last= 0;
+ seqbase.first= seqbase.last= NULL;
+ effbase.first= effbase.last= NULL;
while( (seq= ed->seqbasep->first) ) {
BLI_remlink(ed->seqbasep, seq);
@@ -777,7 +778,7 @@ void sort_seq(Scene *scene)
}
seqt= seqt->next;
}
- if(seqt==0) BLI_addtail(&effbase, seq);
+ if(seqt==NULL) BLI_addtail(&effbase, seq);
}
else {
seqt= seqbase.first;
@@ -788,7 +789,7 @@ void sort_seq(Scene *scene)
}
seqt= seqt->next;
}
- if(seqt==0) BLI_addtail(&seqbase, seq);
+ if(seqt==NULL) BLI_addtail(&seqbase, seq);
}
}
@@ -933,7 +934,7 @@ static void make_black_ibuf(ImBuf *ibuf)
float *rect_float;
int tot;
- if(ibuf==0 || (ibuf->rect==0 && ibuf->rect_float==0)) return;
+ if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return;
tot= ibuf->x*ibuf->y;
@@ -1024,7 +1025,7 @@ StripElem *give_stripelem(Sequence *seq, int cfra)
if(seq->type != SEQ_MOVIE) { /* movie use the first */
int nr = (int) give_stripelem_index(seq, cfra);
- if (nr == -1 || se == 0) return 0;
+ if (nr == -1 || se == NULL) return NULL;
se += nr + seq->anim_startofs;
}
@@ -1076,7 +1077,7 @@ 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] == 0) {
+ if (seq_arr[b] == NULL) {
return 0;
}
} else {
@@ -1134,7 +1135,7 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra,
}
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
- BLI_join_dirfile(name, dir, seq->strip->proxy->file);
+ BLI_join_dirfile(name, FILE_MAX, dir, seq->strip->proxy->file); /* XXX, not real length */
BLI_path_abs(name, G.main->name);
return TRUE;
@@ -1173,38 +1174,38 @@ static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int
char name[PROXY_MAXFILE];
if (!(seq->flag & SEQ_USE_PROXY)) {
- return 0;
+ return NULL;
}
/* rendering at 100% ? No real sense in proxy-ing, right? */
if (context.preview_render_size == 100) {
- return 0;
+ return NULL;
}
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
if (seq->strip->proxy->anim == NULL) {
if (seq_proxy_get_fname(context, seq, cfra, name)==0) {
- return 0;
+ return NULL;
}
seq->strip->proxy->anim = openanim(name, IB_rect);
}
if (seq->strip->proxy->anim==NULL) {
- return 0;
+ return NULL;
}
return IMB_anim_absolute(seq->strip->proxy->anim, frameno);
}
if (seq_proxy_get_fname(context, seq, cfra, name) == 0) {
- return 0;
+ return NULL;
}
if (BLI_exists(name)) {
return IMB_loadiffname(name, IB_rect);
} else {
- return 0;
+ return NULL;
}
}
@@ -1659,7 +1660,7 @@ static ImBuf * input_preprocess(
}
if(seq->flag & SEQ_MAKE_PREMUL) {
- if(ibuf->depth == 32 && ibuf->zbuf == 0) {
+ if(ibuf->depth == 32 && ibuf->zbuf == NULL) {
IMB_premultiply_alpha(ibuf);
}
}
@@ -1678,8 +1679,8 @@ static ImBuf * input_preprocess(
static ImBuf * copy_from_ibuf_still(SeqRenderData context, Sequence * seq,
float nr)
{
- ImBuf * rval = 0;
- ImBuf * ibuf = 0;
+ ImBuf * rval = NULL;
+ ImBuf * ibuf = NULL;
if (nr == 0) {
ibuf = seq_stripelem_cache_get(
@@ -1828,7 +1829,7 @@ static ImBuf* seq_render_effect_strip_impl(
static ImBuf * seq_render_scene_strip_impl(
SeqRenderData context, Sequence * seq, float nr)
{
- ImBuf * ibuf = 0;
+ ImBuf * ibuf = NULL;
float frame= seq->sfra + nr + seq->anim_startofs;
float oldcfra;
Object *oldcamera;
@@ -2043,7 +2044,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
StripElem * s_elem = give_stripelem(seq, cfra);
if (s_elem) {
- BLI_join_dirfile(name, seq->strip->dir, s_elem->name);
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name);
BLI_path_abs(name, G.main->name);
}
@@ -2065,8 +2066,8 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr
}
case SEQ_MOVIE:
{
- if(seq->anim==0) {
- BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name);
+ if(seq->anim==NULL) {
+ BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(name, G.main->name);
seq->anim = openanim(name, IB_rect |
@@ -2248,11 +2249,11 @@ static ImBuf* seq_render_strip_stack(
if (swap_input) {
out = sh.execute(context, seq, cfra,
facf, facf,
- ibuf2, ibuf1, 0);
+ ibuf2, ibuf1, NULL);
} else {
out = sh.execute(context, seq, cfra,
facf, facf,
- ibuf1, ibuf2, 0);
+ ibuf1, ibuf2, NULL);
}
IMB_freeImBuf(ibuf1);
@@ -2641,7 +2642,7 @@ ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown)
}
}
- return e ? e->ibuf : 0;
+ return e ? e->ibuf : NULL;
}
/* Functions to free imbuf and anim data on changes */
@@ -2650,7 +2651,7 @@ static void free_anim_seq(Sequence *seq)
{
if(seq->anim) {
IMB_free_anim(seq->anim);
- seq->anim = 0;
+ seq->anim = NULL;
}
}
@@ -3541,7 +3542,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence
if (seq->strip->proxy) {
seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy);
- seqn->strip->proxy->anim = 0;
+ seqn->strip->proxy->anim = NULL;
}
if (seq->strip->color_balance) {
@@ -3550,19 +3551,19 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence
}
if(seq->type==SEQ_META) {
- seqn->strip->stripdata = 0;
+ seqn->strip->stripdata = NULL;
- seqn->seqbase.first= seqn->seqbase.last= 0;
+ seqn->seqbase.first= seqn->seqbase.last= NULL;
/* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */
/* - seq_dupli_recursive(&seq->seqbase,&seqn->seqbase);*/
} else if(seq->type == SEQ_SCENE) {
- seqn->strip->stripdata = 0;
+ seqn->strip->stripdata = NULL;
if(seq->scene_sound)
seqn->scene_sound = sound_scene_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
} else if(seq->type == SEQ_MOVIE) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
- seqn->anim= 0;
+ seqn->anim= NULL;
} else if(seq->type == SEQ_SOUND) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
@@ -3585,7 +3586,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence
sh.copy(seq, seqn);
}
- seqn->strip->stripdata = 0;
+ seqn->strip->stripdata = NULL;
} else {
fprintf(stderr, "Aiiiiekkk! sequence type not "
@@ -3620,7 +3621,7 @@ Sequence * seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, Sequ
void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag)
{
Sequence *seq;
- Sequence *seqn = 0;
+ Sequence *seqn = NULL;
Sequence *last_seq = seq_active_get(scene);
for(seq= seqbase->first; seq; seq= seq->next) {
diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c
index 753e31d565b..29c29fb5158 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.c
+++ b/source/blender/blenkernel/intern/shrinkwrap.c
@@ -102,7 +102,7 @@ void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float
{
float itarget[4][4];
invert_m4_m4(itarget, target);
- mul_serie_m4(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0);
+ mul_serie_m4(data->local2target, itarget, local, NULL, NULL, NULL, NULL, NULL, NULL);
invert_m4_m4(data->target2local, data->local2target);
}
@@ -378,13 +378,10 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
-
- if(hit.index != -1)
- madd_v3_v3v3fl(hit.co, hit.co, tmp_no, -calc->keepDist);
}
//Project over negative direction of axis
- if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)
+ if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1)
{
float inv_no[3];
negate_v3_v3(inv_no, tmp_no);
@@ -393,14 +390,12 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData);
normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData);
-
- if(hit.index != -1)
- madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
}
if(hit.index != -1)
{
+ madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist);
interp_v3_v3v3(co, co, hit.co, weight);
}
}
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
index 06c6e0f197a..1d5f9b4c463 100644
--- a/source/blender/blenkernel/intern/sketch.c
+++ b/source/blender/blenkernel/intern/sketch.c
@@ -54,7 +54,7 @@ void freeSketch(SK_Sketch *sketch)
MEM_freeN(sketch);
}
-SK_Sketch* createSketch()
+SK_Sketch* createSketch(void)
{
SK_Sketch *sketch;
@@ -102,7 +102,7 @@ void sk_freeStroke(SK_Stroke *stk)
MEM_freeN(stk);
}
-SK_Stroke* sk_createStroke()
+SK_Stroke* sk_createStroke(void)
{
SK_Stroke *stk;
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 3ba18fee615..ca8df76311d 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -161,7 +161,7 @@ typedef struct SB_thread_context {
#define BFF_CLOSEVERT 2 /* collider vertex repulses face */
-float SoftHeunTol = 1.0f; /* humm .. this should be calculated from sb parameters and sizes */
+static float SoftHeunTol = 1.0f; /* humm .. this should be calculated from sb parameters and sizes */
/* local prototypes */
static void free_softbody_intern(SoftBody *sb);
@@ -261,7 +261,7 @@ float operations still
/* just an ID here to reduce the prob for killing objects
** ob->sumohandle points to we should not kill :)
*/
-const int CCD_SAVETY = 190561;
+static const int CCD_SAVETY = 190561;
typedef struct ccdf_minmax{
float minx,miny,minz,maxx,maxy,maxz;
@@ -549,7 +549,7 @@ 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) == 0) {
+ 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 */
@@ -698,12 +698,12 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte
bs = sb->bspring + bp->springs[b-1];
/*nasty thing here that springs have two ends
so here we have to make sure we examine the other */
- if (( v0 == bs->v1) ){
+ if (v0 == bs->v1){
bpo =sb->bpoint+bs->v2;
notthis = bs->v2;
}
else {
- if (( v0 == bs->v2) ){
+ if (v0 == bs->v2){
bpo =sb->bpoint+bs->v1;
notthis = bs->v1;
}
@@ -1647,9 +1647,7 @@ static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow)
ListBase *do_effector = NULL;
do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights);
- if (sb){
- _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
- }
+ _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector);
pdEndEffectors(&do_effector);
}
@@ -1657,7 +1655,7 @@ static void *exec_scan_for_ext_spring_forces(void *data)
{
SB_thread_context *pctx = (SB_thread_context*)data;
_scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->do_effector);
- return 0;
+ return NULL;
}
static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *UNUSED(ptr_to_break_func(void)))
@@ -2384,7 +2382,7 @@ static void *exec_softbody_calc_forces(void *data)
{
SB_thread_context *pctx = (SB_thread_context*)data;
_softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor);
- return 0;
+ return NULL;
}
static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *UNUSED(ptr_to_break_func(void)),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor)
@@ -3824,7 +3822,7 @@ void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscal
{
BodyPoint *bp;
ReferenceVert *rp;
- SoftBody *sb = 0;
+ SoftBody *sb = NULL;
float (*opos)[3];
float (*rpos)[3];
float com[3],rcom[3];
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 3dc2221e0c8..be6c4d22f9c 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -74,7 +74,7 @@ void sound_force_device(int device)
force_device = device;
}
-void sound_init_once()
+void sound_init_once(void)
{
AUD_initOnce();
}
@@ -115,7 +115,7 @@ void sound_init(struct Main *bmain)
#endif
}
-void sound_exit()
+void sound_exit(void)
{
AUD_exit();
}
@@ -382,7 +382,7 @@ void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, i
AUD_moveSequencer(scene->sound_scene, handle, startframe / FPS, endframe / FPS, frameskip / FPS);
}
-void sound_start_play_scene(struct Scene *scene)
+static void sound_start_play_scene(struct Scene *scene)
{
scene->sound_scene_handle = AUD_play(scene->sound_scene, 1);
AUD_setLoop(scene->sound_scene_handle, -1);
diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c
index 7d39203cefc..7ec6d84d285 100644
--- a/source/blender/blenkernel/intern/suggestions.c
+++ b/source/blender/blenkernel/intern/suggestions.c
@@ -77,7 +77,7 @@ static void txttl_free_docs(void) {
/* General tool functions */
/**************************/
-void free_texttools() {
+void free_texttools(void) {
txttl_free_suggest();
txttl_free_docs();
}
@@ -88,7 +88,7 @@ void texttool_text_set_active(Text *text) {
activeToolText = text;
}
-void texttool_text_clear() {
+void texttool_text_clear(void) {
free_texttools();
activeToolText = NULL;
}
@@ -191,15 +191,15 @@ void texttool_suggest_prefix(const char *prefix) {
}
}
-void texttool_suggest_clear() {
+void texttool_suggest_clear(void) {
txttl_free_suggest();
}
-SuggItem *texttool_suggest_first() {
+SuggItem *texttool_suggest_first(void) {
return suggestions.firstmatch;
}
-SuggItem *texttool_suggest_last() {
+SuggItem *texttool_suggest_last(void) {
return suggestions.lastmatch;
}
@@ -207,11 +207,11 @@ void texttool_suggest_select(SuggItem *sel) {
suggestions.selected = sel;
}
-SuggItem *texttool_suggest_selected() {
+SuggItem *texttool_suggest_selected(void) {
return suggestions.selected;
}
-int *texttool_suggest_top() {
+int *texttool_suggest_top(void) {
return &suggestions.top;
}
@@ -243,10 +243,10 @@ void texttool_docs_show(const char *docs) {
documentation[len] = '\0';
}
-char *texttool_docs_get() {
+char *texttool_docs_get(void) {
return documentation;
}
-void texttool_docs_clear() {
+void texttool_docs_clear(void) {
txttl_free_docs();
}
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index de08a3b1813..c22b1d32849 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -51,6 +51,7 @@
#include "DNA_brush_types.h"
#include "DNA_node_types.h"
#include "DNA_color_types.h"
+#include "DNA_particle_types.h"
#include "IMB_imbuf.h"
@@ -92,14 +93,14 @@ void open_plugin_tex(PluginTex *pit)
int (*version)(void);
/* init all the happy variables */
- pit->doit= 0;
- pit->pname= 0;
- pit->stnames= 0;
- pit->varstr= 0;
- pit->result= 0;
- pit->cfra= 0;
+ pit->doit= NULL;
+ pit->pname= NULL;
+ pit->stnames= NULL;
+ pit->varstr= NULL;
+ pit->result= NULL;
+ pit->cfra= NULL;
pit->version= 0;
- pit->instance_init= 0;
+ pit->instance_init= NULL;
/* clear the error list */
PIL_dynlib_get_error_as_string(NULL);
@@ -112,12 +113,12 @@ void open_plugin_tex(PluginTex *pit)
pit->handle= PIL_dynlib_open(pit->name);
if(test_dlerr(pit->name, pit->name)) return;
- if (pit->handle != 0) {
+ if (pit->handle != NULL) {
/* find the address of the version function */
version= (int (*)(void)) PIL_dynlib_find_symbol(pit->handle, "plugin_tex_getversion");
if (test_dlerr(pit->name, "plugin_tex_getversion")) return;
- if (version != 0) {
+ if (version != NULL) {
pit->version= version();
if( pit->version >= 2 && pit->version <=6) {
int (*info_func)(PluginInfo *);
@@ -167,8 +168,8 @@ PluginTex *add_plugin_tex(char *str)
strcpy(pit->name, str);
open_plugin_tex(pit);
- if(pit->doit==0) {
- if(pit->handle==0) {;} //XXX error("no plugin: %s", str);
+ if(pit->doit==NULL) {
+ if(pit->handle==NULL) {;} //XXX error("no plugin: %s", str);
else {;} //XXX error("in plugin: %s", str);
MEM_freeN(pit);
return NULL;
@@ -192,7 +193,7 @@ PluginTex *add_plugin_tex(char *str)
void free_plugin_tex(PluginTex *pit)
{
- if(pit==0) return;
+ if(pit==NULL) return;
/* no PIL_dynlib_close: same plugin can be opened multiple times, 1 handle */
MEM_freeN(pit);
@@ -618,7 +619,7 @@ void default_mtex(MTex *mtex)
{
mtex->texco= TEXCO_ORCO;
mtex->mapto= MAP_COL;
- mtex->object= 0;
+ mtex->object= NULL;
mtex->projx= PROJ_X;
mtex->projy= PROJ_Y;
mtex->projz= PROJ_Z;
@@ -629,7 +630,7 @@ void default_mtex(MTex *mtex)
mtex->size[0]= 1.0;
mtex->size[1]= 1.0;
mtex->size[2]= 1.0;
- mtex->tex= 0;
+ mtex->tex= NULL;
mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE;
mtex->colormodel= 0;
mtex->r= 1.0;
@@ -671,14 +672,16 @@ void default_mtex(MTex *mtex)
mtex->lifefac= 1.0f;
mtex->sizefac= 1.0f;
mtex->ivelfac= 1.0f;
- mtex->pvelfac= 1.0f;
+ mtex->dampfac= 1.0f;
+ mtex->gravityfac= 1.0f;
+ mtex->fieldfac= 1.0f;
mtex->normapspace= MTEX_NSPACE_TANGENT;
}
/* ------------------------------------------------------------------------- */
-MTex *add_mtex()
+MTex *add_mtex(void)
{
MTex *mtex;
@@ -740,7 +743,7 @@ Tex *copy_texture(Tex *tex)
texn= copy_libblock(tex);
if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima);
- else texn->ima= 0;
+ else texn->ima= NULL;
#if 0 // XXX old animation system
id_us_plus((ID *)texn->ipo);
@@ -760,7 +763,7 @@ Tex *copy_texture(Tex *tex)
if(tex->nodetree) {
ntreeEndExecTree(tex->nodetree);
- texn->nodetree= ntreeCopyTree(tex->nodetree, 0); /* 0 == full new tree */
+ texn->nodetree= ntreeCopyTree(tex->nodetree); /* 0 == full new tree */
}
return texn;
@@ -776,6 +779,7 @@ void make_local_texture(Tex *tex)
World *wrld;
Lamp *la;
Brush *br;
+ ParticleSettings *pa;
int a, local=0, lib=0;
/* - only lib users: do nothing
@@ -783,19 +787,19 @@ void make_local_texture(Tex *tex)
* - mixed: make copy
*/
- if(tex->id.lib==0) return;
+ if(tex->id.lib==NULL) return;
/* special case: ima always local immediately */
if(tex->ima) {
- tex->ima->id.lib= 0;
+ tex->ima->id.lib= NULL;
tex->ima->id.flag= LIB_LOCAL;
- new_id(0, (ID *)tex->ima, 0);
+ new_id(NULL, (ID *)tex->ima, NULL);
}
if(tex->id.us==1) {
- tex->id.lib= 0;
+ tex->id.lib= NULL;
tex->id.flag= LIB_LOCAL;
- new_id(0, (ID *)tex, 0);
+ new_id(NULL, (ID *)tex, NULL);
return;
}
@@ -838,11 +842,21 @@ void make_local_texture(Tex *tex)
}
br= br->id.next;
}
+ pa= bmain->particle.first;
+ while(pa) {
+ for(a=0; a<MAX_MTEX; a++) {
+ if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
+ if(pa->id.lib) lib= 1;
+ else local= 1;
+ }
+ }
+ pa= pa->id.next;
+ }
if(local && lib==0) {
- tex->id.lib= 0;
+ tex->id.lib= NULL;
tex->id.flag= LIB_LOCAL;
- new_id(0, (ID *)tex, 0);
+ new_id(NULL, (ID *)tex, NULL);
}
else if(local && lib) {
texn= copy_texture(tex);
@@ -852,7 +866,7 @@ void make_local_texture(Tex *tex)
while(ma) {
for(a=0; a<MAX_MTEX; a++) {
if(ma->mtex[a] && ma->mtex[a]->tex==tex) {
- if(ma->id.lib==0) {
+ if(ma->id.lib==NULL) {
ma->mtex[a]->tex= texn;
texn->id.us++;
tex->id.us--;
@@ -865,7 +879,7 @@ void make_local_texture(Tex *tex)
while(la) {
for(a=0; a<MAX_MTEX; a++) {
if(la->mtex[a] && la->mtex[a]->tex==tex) {
- if(la->id.lib==0) {
+ if(la->id.lib==NULL) {
la->mtex[a]->tex= texn;
texn->id.us++;
tex->id.us--;
@@ -878,7 +892,7 @@ void make_local_texture(Tex *tex)
while(wrld) {
for(a=0; a<MAX_MTEX; a++) {
if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) {
- if(wrld->id.lib==0) {
+ if(wrld->id.lib==NULL) {
wrld->mtex[a]->tex= texn;
texn->id.us++;
tex->id.us--;
@@ -890,7 +904,7 @@ void make_local_texture(Tex *tex)
br= bmain->brush.first;
while(br) {
if(br->mtex.tex==tex) {
- if(br->id.lib==0) {
+ if(br->id.lib==NULL) {
br->mtex.tex= texn;
texn->id.us++;
tex->id.us--;
@@ -898,6 +912,19 @@ void make_local_texture(Tex *tex)
}
br= br->id.next;
}
+ pa= bmain->particle.first;
+ while(pa) {
+ for(a=0; a<MAX_MTEX; a++) {
+ if(pa->mtex[a] && pa->mtex[a]->tex==tex) {
+ if(pa->id.lib==NULL) {
+ pa->mtex[a]->tex= texn;
+ texn->id.us++;
+ tex->id.us--;
+ }
+ }
+ }
+ pa= pa->id.next;
+ }
}
}
@@ -940,8 +967,8 @@ Tex *give_current_object_texture(Object *ob)
Material *ma;
Tex *tex= NULL;
- if(ob==0) return 0;
- if(ob->totcol==0 && !(ob->type==OB_LAMP)) return 0;
+ if(ob==NULL) return NULL;
+ if(ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL;
if(ob->type==OB_LAMP) {
tex= give_current_lamp_texture(ob->data);
@@ -1048,6 +1075,10 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
*mtex_ar= ((Lamp *)id)->mtex;
if(act) *act= (((Lamp *)id)->texact);
break;
+ case ID_PA:
+ *mtex_ar= ((ParticleSettings *)id)->mtex;
+ if(act) *act= (((ParticleSettings *)id)->texact);
+ break;
default:
*mtex_ar = NULL;
if(act) *act= 0;
@@ -1072,6 +1103,9 @@ void set_active_mtex(ID *id, short act)
case ID_LA:
((Lamp *)id)->texact= act;
break;
+ case ID_PA:
+ ((ParticleSettings *)id)->texact= act;
+ break;
}
}
@@ -1121,7 +1155,7 @@ Tex *give_current_world_texture(World *world)
MTex *mtex= NULL;
Tex *tex= NULL;
- if(!world) return 0;
+ if(!world) return NULL;
mtex= world->mtex[(int)(world->texact)];
if(mtex) tex= mtex->tex;
@@ -1167,6 +1201,42 @@ void set_current_brush_texture(Brush *br, Tex *newtex)
}
}
+Tex *give_current_particle_texture(ParticleSettings *part)
+{
+ MTex *mtex= NULL;
+ Tex *tex= NULL;
+
+ if(!part) return NULL;
+
+ mtex= part->mtex[(int)(part->texact)];
+ if(mtex) tex= mtex->tex;
+
+ return tex;
+}
+
+void set_current_particle_texture(ParticleSettings *part, Tex *newtex)
+{
+ int act= part->texact;
+
+ if(part->mtex[act] && part->mtex[act]->tex)
+ id_us_min(&part->mtex[act]->tex->id);
+
+ if(newtex) {
+ if(!part->mtex[act]) {
+ part->mtex[act]= add_mtex();
+ part->mtex[act]->texco= TEXCO_ORCO;
+ part->mtex[act]->blendtype= MTEX_MUL;
+ }
+
+ part->mtex[act]->tex= newtex;
+ id_us_plus(&newtex->id);
+ }
+ else if(part->mtex[act]) {
+ MEM_freeN(part->mtex[act]);
+ part->mtex[act]= NULL;
+ }
+}
+
/* ------------------------------------------------------------------------- */
EnvMap *BKE_add_envmap(void)
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 1b04589c1f2..c3a34e1942f 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -264,10 +264,10 @@ static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, s
#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1)
static struct bUnitCollection *bUnitSystems[][9] = {
- {0, 0, 0, 0, 0, &buNaturalRotCollection, &buNaturalTimeCollecton, 0, 0},
- {0, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */
- {0, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */
- {0, 0, 0, 0, 0, 0, 0, 0, 0}
+ {NULL, NULL, NULL, NULL, NULL, &buNaturalRotCollection, &buNaturalTimeCollecton, NULL, NULL},
+ {NULL, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */
+ {NULL, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */
+ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
};
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index a86b039e918..5412e44f0eb 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -38,6 +38,7 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
+#include "BKE_world.h"
#include "BKE_library.h"
#include "BKE_animsys.h"
#include "BKE_global.h"
@@ -136,11 +137,11 @@ void make_local_world(World *wrld)
* - mixed: make copy
*/
- if(wrld->id.lib==0) return;
+ if(wrld->id.lib==NULL) return;
if(wrld->id.us==1) {
- wrld->id.lib= 0;
+ wrld->id.lib= NULL;
wrld->id.flag= LIB_LOCAL;
- new_id(0, (ID *)wrld, 0);
+ new_id(NULL, (ID *)wrld, NULL);
return;
}
@@ -156,7 +157,7 @@ void make_local_world(World *wrld)
if(local && lib==0) {
wrld->id.lib= 0;
wrld->id.flag= LIB_LOCAL;
- new_id(0, (ID *)wrld, 0);
+ new_id(NULL, (ID *)wrld, NULL);
}
else if(local && lib) {
wrldn= copy_world(wrld);
@@ -165,7 +166,7 @@ void make_local_world(World *wrld)
sce= bmain->scene.first;
while(sce) {
if(sce->world==wrld) {
- if(sce->id.lib==0) {
+ if(sce->id.lib==NULL) {
sce->world= wrldn;
wrldn->id.us++;
wrld->id.us--;