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-10-11 01:15:11 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2011-10-11 01:15:11 +0400
commitd546002476a849524ba938c53a5d9e9a81c50ded (patch)
tree37a5b2b8eec0832779cfd9bc172e0ac29d3098e6 /source/blender/blenkernel/intern
parent28cc31ba11f805c4cac2a250b4181ec9c556b8da (diff)
parent9cabc57a62e8db17edd09839d7ae200239fb3618 (diff)
Merged changes in the trunk up to revision 40911.
Conflicts resolved: source/blender/blenloader/intern/readfile.c
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/BME_conversions.c14
-rw-r--r--source/blender/blenkernel/intern/BME_structure.c8
-rw-r--r--source/blender/blenkernel/intern/BME_tools.c38
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.c3
-rw-r--r--source/blender/blenkernel/intern/CCGSubSurf.h3
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c197
-rw-r--r--source/blender/blenkernel/intern/action.c4
-rw-r--r--source/blender/blenkernel/intern/anim.c6
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c5
-rw-r--r--source/blender/blenkernel/intern/armature.c2
-rw-r--r--source/blender/blenkernel/intern/blender.c7
-rw-r--r--source/blender/blenkernel/intern/bmfont.c6
-rw-r--r--source/blender/blenkernel/intern/boids.c7
-rw-r--r--source/blender/blenkernel/intern/bullet.c3
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c1
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c71
-rw-r--r--source/blender/blenkernel/intern/cloth.c4
-rw-r--r--source/blender/blenkernel/intern/collision.c9
-rw-r--r--source/blender/blenkernel/intern/colortools.c78
-rw-r--r--source/blender/blenkernel/intern/constraint.c5
-rw-r--r--source/blender/blenkernel/intern/curve.c178
-rw-r--r--source/blender/blenkernel/intern/customdata.c68
-rw-r--r--source/blender/blenkernel/intern/deform.c9
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c14
-rw-r--r--source/blender/blenkernel/intern/displist.c9
-rw-r--r--source/blender/blenkernel/intern/effect.c4
-rw-r--r--source/blender/blenkernel/intern/fcurve.c15
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c2
-rw-r--r--source/blender/blenkernel/intern/font.c32
-rw-r--r--source/blender/blenkernel/intern/gpencil.c4
-rw-r--r--source/blender/blenkernel/intern/icons.c56
-rw-r--r--source/blender/blenkernel/intern/idcode.c3
-rw-r--r--source/blender/blenkernel/intern/image.c24
-rw-r--r--source/blender/blenkernel/intern/image_gen.c3
-rw-r--r--source/blender/blenkernel/intern/implicit.c14
-rw-r--r--source/blender/blenkernel/intern/ipo.c8
-rw-r--r--source/blender/blenkernel/intern/key.c11
-rw-r--r--source/blender/blenkernel/intern/lattice.c3
-rw-r--r--source/blender/blenkernel/intern/library.c4
-rw-r--r--source/blender/blenkernel/intern/material.c58
-rw-r--r--source/blender/blenkernel/intern/mball.c16
-rw-r--r--source/blender/blenkernel/intern/mesh.c22
-rw-r--r--source/blender/blenkernel/intern/modifier.c68
-rw-r--r--source/blender/blenkernel/intern/multires.c2
-rw-r--r--source/blender/blenkernel/intern/navmesh_conversion.c73
-rw-r--r--source/blender/blenkernel/intern/nla.c10
-rw-r--r--source/blender/blenkernel/intern/node.c2
-rw-r--r--source/blender/blenkernel/intern/object.c85
-rw-r--r--source/blender/blenkernel/intern/packedFile.c12
-rw-r--r--source/blender/blenkernel/intern/particle.c5
-rw-r--r--source/blender/blenkernel/intern/particle_system.c128
-rw-r--r--source/blender/blenkernel/intern/pointcache.c3
-rw-r--r--source/blender/blenkernel/intern/property.c7
-rw-r--r--source/blender/blenkernel/intern/sca.c6
-rw-r--r--source/blender/blenkernel/intern/scene.c15
-rw-r--r--source/blender/blenkernel/intern/script.c6
-rw-r--r--source/blender/blenkernel/intern/seqcache.c2
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c11
-rw-r--r--source/blender/blenkernel/intern/sequencer.c7
-rw-r--r--source/blender/blenkernel/intern/sketch.c1
-rw-r--r--source/blender/blenkernel/intern/smoke.c2
-rw-r--r--source/blender/blenkernel/intern/softbody.c19
-rw-r--r--source/blender/blenkernel/intern/sound.c9
-rw-r--r--source/blender/blenkernel/intern/speaker.c4
-rw-r--r--source/blender/blenkernel/intern/text.c13
-rw-r--r--source/blender/blenkernel/intern/texture.c10
-rw-r--r--source/blender/blenkernel/intern/world.c5
-rw-r--r--source/blender/blenkernel/intern/writeavi.c7
-rw-r--r--source/blender/blenkernel/intern/writeffmpeg.c31
-rw-r--r--source/blender/blenkernel/intern/writeframeserver.c11
70 files changed, 996 insertions, 586 deletions
diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c
index 2aff2b78b72..4016cf00ae4 100644
--- a/source/blender/blenkernel/intern/BME_conversions.c
+++ b/source/blender/blenkernel/intern/BME_conversions.c
@@ -354,7 +354,7 @@ void BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em) {
BME_TransData *vtd;
- EditVert *eve1, *eve2, *eve3, *eve4, **evlist;
+ EditVert *eve1, /* *eve2, *eve3, *eve4, */ /* UNUSED */ **evlist;
EditEdge *eed;
EditFace *efa;
@@ -412,14 +412,14 @@ void BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em) {
len = BME_cycle_length(f->loopbase);
if (len==3 || len==4) {
eve1= evlist[f->loopbase->v->tflag1];
- eve2= evlist[f->loopbase->next->v->tflag1];
- eve3= evlist[f->loopbase->next->next->v->tflag1];
- if (len == 4) {
+ /* eve2= evlist[f->loopbase->next->v->tflag1]; */ /* UNUSED */
+ /* eve3= evlist[f->loopbase->next->next->v->tflag1]; */ /* UNUSED */
+ /* if (len == 4) {
eve4= evlist[f->loopbase->prev->v->tflag1];
}
else {
eve4= NULL;
- }
+ } */ /* UNUSED */
efa = NULL; //XXX addfacelist(eve1, eve2, eve3, eve4, NULL, NULL);
efa->mat_nr = (unsigned char)f->mat_nr;
@@ -541,7 +541,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
MEdge *medge, *me;
MVert *mvert, *mv;
int *origindex;
- int totface,totedge,totvert,i,bmeshok,len, numTex, numCol;
+ int totface, totedge, totvert, i, /* bmeshok, */ /* UNUSED */ len, numTex, numCol;
BME_Vert *v1=NULL;
BME_Edge *e=NULL, *oe=NULL;
@@ -569,7 +569,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm)
/*count quads and tris*/
totface = 0;
- bmeshok = 1;
+ /* bmeshok = 1; */ /* UNUSED */
for(f=bm->polys.first;f;f=f->next){
len = BME_cycle_length(f->loopbase);
if(len == 3 || len == 4) totface++;
diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c
index 1b6c499a9fa..bd5241adb6b 100644
--- a/source/blender/blenkernel/intern/BME_structure.c
+++ b/source/blender/blenkernel/intern/BME_structure.c
@@ -503,16 +503,16 @@ void BME_disk_remove_edge(BME_Edge *e, BME_Vert *v)
BME_Edge *BME_disk_next_edgeflag(BME_Edge *e, BME_Vert *v, int eflag, int tflag){
- BME_CycleNode *diskbase;
+ /* BME_CycleNode *diskbase; */ /* UNUSED */
BME_Edge *curedge;
- int len, ok;
+ int /* len, */ /* UNUSED */ ok;
if(eflag && tflag) return NULL;
ok = BME_vert_in_edge(e,v);
if(ok){
- diskbase = BME_disk_getpointer(e, v);
- len = BME_cycle_length(diskbase);
+ /* diskbase = BME_disk_getpointer(e, v); */ /* UNUSED */
+ /* len = BME_cycle_length(diskbase); */ /* UNUSED */
curedge = BME_disk_nextedge(e,v);
while(curedge != e){
if(tflag){
diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c
index 99b6e7f9095..a95d149f058 100644
--- a/source/blender/blenkernel/intern/BME_tools.c
+++ b/source/blender/blenkernel/intern/BME_tools.c
@@ -393,19 +393,19 @@ static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int
* and transform properties, and set the max limits.
* Finally, return the split vert. */
static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, BME_Loop *l, float *up_vec, float value, BME_TransData_Head *td) {
- BME_TransData *vtd, *vtd1, *vtd2;
- BME_Vert *sv, *v2, *v3, *ov;
+ BME_TransData *vtd, *vtd1 /* , *vtd2 */ /* UNUSED */;
+ BME_Vert *sv, *v2, *v3 /* , *ov */ /* UNUSED */;
BME_Loop *lv1, *lv2;
BME_Edge *ne, *e1, *e2;
float maxfactor, scale, len, dis, vec1[3], vec2[3], t_up_vec[3];
- int is_edge, forward, is_split_vert;
+ int is_edge, forward /* , is_split_vert */ /* UNUSED */;
if (l == NULL) {
/* what you call operator overloading in C :)
* I wanted to use the same function for both wire edges and poly loops
* so... here we walk around edges to find the needed verts */
forward = 1;
- is_split_vert = 0;
+ /* is_split_vert = 0; */ /* UNUSED */
if (v->edge == NULL) {
//printf("We can't split a loose vert's edge!\n");
return NULL;
@@ -428,7 +428,7 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
else {
e1 = e2;
}
- ov = BME_edge_getothervert(e1,v);
+ /* ov = BME_edge_getothervert(e1,v); */ /* UNUSED */
sv = BME_split_edge(bm,v,e1,&ne,0);
//BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/
//BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
@@ -464,14 +464,14 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
}
if (BME_bevel_is_split_vert(lv1)) {
- is_split_vert = 1;
+ /* is_split_vert = 1; */ /* UNUSED */
sv = v1;
if (forward) v1 = l->next->next->v;
else v1 = l->prev->v;
}
else {
- is_split_vert = 0;
- ov = BME_edge_getothervert(l->e,v);
+ /* is_split_vert = 0; */ /* UNUSED */
+ /* ov = BME_edge_getothervert(l->e,v); */ /* UNUSED */
sv = BME_split_edge(bm,v,l->e,&ne,0);
//BME_data_interp_from_verts(bm, v, ov, sv, 0.25); /*this is technically wrong...*/
//BME_data_interp_from_faceverts(bm, v, ov, sv, 0.25);
@@ -494,7 +494,7 @@ static BME_Vert *BME_bevel_split_edge(BME_Mesh *bm, BME_Vert *v, BME_Vert *v1, B
vtd = BME_get_transdata(td, sv);
vtd1 = BME_get_transdata(td, v);
- vtd2 = BME_get_transdata(td,v1);
+ /* vtd2 = BME_get_transdata(td,v1); */ /* UNUSED */
if (vtd1->loc == NULL) {
/* this is a vert with data only for calculating initial weights */
@@ -717,7 +717,7 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int UNUS
static BME_Loop *BME_bevel_vert(BME_Mesh *bm, BME_Loop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td) {
BME_Vert *v1, *v2;
- BME_Poly *f;
+ /* BME_Poly *f; */ /* UNUSED */
/* get/make the first vert to be used in SFME */
/* may need to split the previous edge */
@@ -730,7 +730,7 @@ static BME_Loop *BME_bevel_vert(BME_Mesh *bm, BME_Loop *l, float value, int UNUS
l = l->next->next;
/* "cut off" this corner */
- f = BME_split_face(bm,l->f,v2,v1,NULL,l->e);
+ /* f = */ /* UNUSED */ BME_split_face(bm,l->f,v2,v1,NULL,l->e);
return l;
}
@@ -929,16 +929,16 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int UNUSED(defg
BME_Vert *v;
BME_Edge *e;
BME_Poly *f;
- BME_TransData *vtd;
- MDeformVert *dvert;
- MDeformWeight *dw;
+ /* BME_TransData *vtd; */ /* UNUSED */
+ /* MDeformVert *dvert; */ /* UNUSED */
+ /* MDeformWeight *dw; */ /* UNUSED */
int len;
float weight, threshold;
/* vert pass */
for (v=bm->verts.first; v; v=v->next) {
- dvert = NULL;
- dw = NULL;
+ /* dvert = NULL; */ /* UNUSED */
+ /* dw = NULL; */ /* UNUSED */
v->tflag1 = BME_BEVEL_ORIG;
/* originally coded, a vertex gets tagged with BME_BEVEL_BEVEL in this pass if
* the vert is manifold (or is shared by only two edges - wire bevel)
@@ -962,7 +962,7 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int UNUSED(defg
else {
len = BME_cycle_length(BME_disk_getpointer(v->edge,v));
/* we'll assign a default transform data to every vert (except the loose ones) */
- vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL);
+ /* vtd = */ /* UNUSED */ BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 0, -1, -1, NULL);
}
/* check for non-manifold vert */
@@ -990,11 +990,11 @@ static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int UNUSED(defg
//~ }
//~ if (!dw || dw->weight == 0.0) continue;
if (v->bweight == 0.0) continue;
- vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, v->bweight, -1, NULL);
+ /* vtd = */ /* UNUSED */ BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, v->bweight, -1, NULL);
v->tflag1 |= BME_BEVEL_BEVEL;
}
else {
- vtd = BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, 1.0, -1, NULL);
+ /* vtd = */ /* UNUSED */ BME_assign_transdata(td, bm, v, v->co, v->co, NULL, NULL, 1.0, 1.0, -1, NULL);
v->tflag1 |= BME_BEVEL_BEVEL;
}
}
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c
index a311ca15e5e..bf9acb224d5 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.c
+++ b/source/blender/blenkernel/intern/CCGSubSurf.c
@@ -1,7 +1,8 @@
+/* $Id$ */
+
/** \file blender/blenkernel/intern/CCGSubSurf.c
* \ingroup bke
*/
-/* $Id$ */
#include <stdlib.h>
#include <string.h>
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h
index 363d1e01f98..1835e63727d 100644
--- a/source/blender/blenkernel/intern/CCGSubSurf.h
+++ b/source/blender/blenkernel/intern/CCGSubSurf.h
@@ -1,7 +1,8 @@
+/* $Id$ */
+
/** \file blender/blenkernel/intern/CCGSubSurf.h
* \ingroup bke
*/
-/* $Id$ */
typedef void* CCGMeshHDL;
typedef void* CCGVertHDL;
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index e3440e183e3..c52bcbadf35 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -62,6 +62,10 @@
#include "BKE_multires.h"
#include "BKE_armature.h"
+#ifdef WITH_GAMEENGINE
+#include "BKE_navmesh_conversion.h"
+#endif
+
#include "BLO_sys_types.h" // for intptr_t support
#include "GL/glew.h"
@@ -73,6 +77,8 @@
extern GLubyte stipple_quarttone[128]; /* glutil.c, bad level data */
+static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
+
///////////////////////////////////
///////////////////////////////////
@@ -691,9 +697,11 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
else {
const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT;
if (shade_type != shade_prev) {
- glShadeModel((shade_prev= shade_type));
+ if(poly_prev != GL_ZERO) glEnd();
+ glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */
+ glBegin((poly_prev= poly_type));
}
- if(poly_type != poly_prev) {
+ else if(poly_type != poly_prev) {
if(poly_prev != GL_ZERO) glEnd();
glBegin((poly_prev= poly_type));
}
@@ -756,9 +764,11 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
else {
const GLenum shade_type= drawSmooth ? GL_SMOOTH : GL_FLAT;
if (shade_type != shade_prev) {
- glShadeModel((shade_prev= shade_type));
+ if(poly_prev != GL_ZERO) glEnd();
+ glShadeModel((shade_prev= shade_type)); /* same as below but switch shading */
+ glBegin((poly_prev= poly_type));
}
- if(poly_type != poly_prev) {
+ else if(poly_type != poly_prev) {
if(poly_prev != GL_ZERO) glEnd();
glBegin((poly_prev= poly_type));
}
@@ -2107,6 +2117,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
add_orco_dm(ob, NULL, *deform_r, NULL, CD_ORCO);
}
+#ifdef WITH_GAMEENGINE
+ /* NavMesh - this is a hack but saves having a NavMesh modifier */
+ if ((ob->gameflag & OB_NAVMESH) && (finaldm->type == DM_TYPE_CDDM)) {
+ DerivedMesh *tdm;
+ tdm= navmesh_dm_createNavMeshForVisualization(finaldm);
+ if (finaldm != tdm) {
+ finaldm->release(finaldm);
+ finaldm= tdm;
+ }
+ }
+#endif /* WITH_GAMEENGINE */
+
*final_r = finaldm;
if(orcodm)
@@ -2941,3 +2963,170 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm)
boundbox_set_from_min_max(ob->bb, min, max);
}
+
+/* --- NAVMESH (begin) --- */
+#ifdef WITH_GAMEENGINE
+
+BM_INLINE int navmesh_bit(int a, int b)
+{
+ return (a & (1 << b)) >> b;
+}
+
+BM_INLINE void navmesh_intToCol(int i, float col[3])
+{
+ int r = navmesh_bit(i, 0) + navmesh_bit(i, 3) * 2 + 1;
+ int g = navmesh_bit(i, 1) + navmesh_bit(i, 4) * 2 + 1;
+ int b = navmesh_bit(i, 2) + navmesh_bit(i, 5) * 2 + 1;
+ col[0] = 1 - r*63.0f/255.0f;
+ col[1] = 1 - g*63.0f/255.0f;
+ col[2] = 1 - b*63.0f/255.0f;
+}
+
+static void navmesh_drawColored(DerivedMesh *dm)
+{
+ int a, glmode;
+ MVert *mvert = (MVert *)CustomData_get_layer(&dm->vertData, CD_MVERT);
+ MFace *mface = (MFace *)CustomData_get_layer(&dm->faceData, CD_MFACE);
+ int *polygonIdx = (int *)CustomData_get_layer(&dm->faceData, CD_RECAST);
+ float col[3];
+
+ if (!polygonIdx)
+ return;
+
+ /*
+ //UI_ThemeColor(TH_WIRE);
+ glDisable(GL_LIGHTING);
+ glLineWidth(2.0);
+ dm->drawEdges(dm, 0, 1);
+ glLineWidth(1.0);
+ glEnable(GL_LIGHTING);*/
+
+ glDisable(GL_LIGHTING);
+ /* if(GPU_buffer_legacy(dm) ) */ { /* TODO - VBO draw code, not high priority - campbell */
+ DEBUG_VBO( "Using legacy code. drawNavMeshColored\n" );
+ //glShadeModel(GL_SMOOTH);
+ glBegin(glmode = GL_QUADS);
+ for(a = 0; a < dm->numFaceData; a++, mface++) {
+ int new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES;
+ int pi = polygonIdx[a];
+ if (pi <= 0) {
+ zero_v3(col);
+ }
+ else {
+ navmesh_intToCol(pi, col);
+ }
+
+ if(new_glmode != glmode) {
+ glEnd();
+ glBegin(glmode = new_glmode);
+ }
+ glColor3fv(col);
+ glVertex3fv(mvert[mface->v1].co);
+ glVertex3fv(mvert[mface->v2].co);
+ glVertex3fv(mvert[mface->v3].co);
+ if(mface->v4) {
+ glVertex3fv(mvert[mface->v4].co);
+ }
+ }
+ glEnd();
+ }
+ glEnable(GL_LIGHTING);
+}
+
+static void navmesh_DM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tface, int has_mcol, int matnr))
+{
+ (void) setDrawOptions;
+
+ navmesh_drawColored(dm);
+}
+
+static void navmesh_DM_drawFacesSolid(DerivedMesh *dm,
+ float (*partial_redraw_planes)[4],
+ int UNUSED(fast), int (*setMaterial)(int, void *attribs))
+{
+ (void) partial_redraw_planes;
+ (void) setMaterial;
+
+ //drawFacesSolid_original(dm, partial_redraw_planes, fast, setMaterial);
+ navmesh_drawColored(dm);
+}
+
+static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm)
+{
+ DerivedMesh *result;
+ int maxFaces = dm->getNumFaces(dm);
+ int *recastData;
+ int vertsPerPoly=0, nverts=0, ndtris=0, npolys=0;
+ float* verts=NULL;
+ unsigned short *dtris=NULL, *dmeshes=NULL, *polys=NULL;
+ int *dtrisToPolysMap=NULL, *dtrisToTrisMap=NULL, *trisToFacesMap=NULL;
+ int res;
+
+ result = CDDM_copy(dm);
+ if (!CustomData_has_layer(&result->faceData, CD_RECAST)) {
+ int *sourceRecastData = (int*)CustomData_get_layer(&dm->faceData, CD_RECAST);
+ if (sourceRecastData) {
+ CustomData_add_layer_named(&result->faceData, CD_RECAST, CD_DUPLICATE,
+ sourceRecastData, maxFaces, "recastData");
+ }
+ }
+ recastData = (int*)CustomData_get_layer(&result->faceData, CD_RECAST);
+
+ /* note: This is not good design! - really should not be doing this */
+ result->drawFacesTex = navmesh_DM_drawFacesTex;
+ result->drawFacesSolid = navmesh_DM_drawFacesSolid;
+
+
+ /* process mesh */
+ res = buildNavMeshDataByDerivedMesh(dm, &vertsPerPoly, &nverts, &verts, &ndtris, &dtris,
+ &npolys, &dmeshes, &polys, &dtrisToPolysMap, &dtrisToTrisMap,
+ &trisToFacesMap);
+ if (res) {
+ size_t polyIdx;
+
+ /* invalidate concave polygon */
+ for (polyIdx=0; polyIdx<(size_t)npolys; polyIdx++) {
+ unsigned short* poly = &polys[polyIdx*2*vertsPerPoly];
+ if (!polyIsConvex(poly, vertsPerPoly, verts)) {
+ /* set negative polygon idx to all faces */
+ unsigned short *dmesh = &dmeshes[4*polyIdx];
+ unsigned short tbase = dmesh[2];
+ unsigned short tnum = dmesh[3];
+ unsigned short ti;
+
+ for (ti=0; ti<tnum; ti++) {
+ unsigned short triidx = dtrisToTrisMap[tbase+ti];
+ unsigned short faceidx = trisToFacesMap[triidx];
+ if (recastData[faceidx] > 0) {
+ recastData[faceidx] = -recastData[faceidx];
+ }
+ }
+ }
+ }
+ }
+ else {
+ printf("Error during creation polygon infos\n");
+ }
+
+ /* clean up */
+ if (verts!=NULL)
+ MEM_freeN(verts);
+ if (dtris!=NULL)
+ MEM_freeN(dtris);
+ if (dmeshes!=NULL)
+ MEM_freeN(dmeshes);
+ if (polys!=NULL)
+ MEM_freeN(polys);
+ if (dtrisToPolysMap!=NULL)
+ MEM_freeN(dtrisToPolysMap);
+ if (dtrisToTrisMap!=NULL)
+ MEM_freeN(dtrisToTrisMap);
+ if (trisToFacesMap!=NULL)
+ MEM_freeN(trisToFacesMap);
+
+ return result;
+}
+
+#endif /* WITH_GAMEENGINE */
+
+/* --- NAVMESH (end) --- */
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 73ddcbecf94..8b9f5ac98d3 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -270,7 +272,7 @@ bActionGroup *action_groups_add_new (bAction *act, const char name[])
/* make it selected, with default name */
agrp->flag = AGRP_SELECTED;
- strncpy(agrp->name, name[0] ? name : "Group", sizeof(agrp->name));
+ BLI_strncpy(agrp->name, name[0] ? name : "Group", sizeof(agrp->name));
/* add to action, and validate */
BLI_addtail(&act->groups, agrp);
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 824bbb8f70d..cd2c272a1c2 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -1,4 +1,6 @@
-/*
+/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -1514,7 +1516,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);
+ chartransdata= BKE_text_to_curve(G.main, scene, par, FO_DUPLI);
if(chartransdata==NULL) return;
cu= par->data;
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 44c61fa6dcf..8ed255e688c 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -1167,6 +1169,8 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
return 0;
}
+ /* RNA property update disabled for now - [#28525] [#28690] [#28774] [#28777] */
+#if 0
/* buffer property update for later flushing */
if (RNA_property_update_check(prop)) {
short skip_updates_hack = 0;
@@ -1183,6 +1187,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i
if (skip_updates_hack == 0)
RNA_property_update_cache_add(&new_ptr, prop);
}
+#endif
}
/* successful */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 1149d8eee25..fbbce58414e 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 27ea1585e4b..5358a26e660 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -1,7 +1,4 @@
-/* blender.c jan 94 MIXED MODEL
- *
- * common help functions and data
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -518,7 +515,7 @@ void BKE_write_undo(bContext *C, const char *name)
/* make new */
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file");
- strncpy(uel->name, name, MAXUNDONAME-1);
+ BLI_strncpy(uel->name, name, sizeof(uel->name));
BLI_addtail(&undobase, uel);
/* and limit amount to the maximum */
diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c
index 6b1f313d88d..d73d7509644 100644
--- a/source/blender/blenkernel/intern/bmfont.c
+++ b/source/blender/blenkernel/intern/bmfont.c
@@ -1,8 +1,4 @@
/*
- * bmfont.c
- *
- * 04-10-2000 frank
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,7 +22,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): 04-10-2000 frank.
*
* ***** END GPL LICENSE BLOCK *****
*
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 3966caa1fa9..2a478d4ffe2 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -1,6 +1,4 @@
-/* boids.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -908,7 +906,8 @@ static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val,
else
return 0;
}
-static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa) {
+static BoidState *get_boid_state(BoidSettings *boids, ParticleData *pa)
+{
BoidState *state = boids->states.first;
BoidParticle *bpa = pa->boid;
diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c
index 72f5e907800..e4a02434cba 100644
--- a/source/blender/blenkernel/intern/bullet.c
+++ b/source/blender/blenkernel/intern/bullet.c
@@ -1,5 +1,4 @@
-/*
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index c3aeb440938..2ce6b92922d 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -1,5 +1,4 @@
/*
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index bf462868271..0022710e580 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -1,41 +1,41 @@
/*
-* $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) 2006 Blender Foundation.
-* All rights reserved.
-*
-* The Original Code is: all of this file.
-*
-* Contributor(s): Ben Batt <benbatt@gmail.com>
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-* Implementation of CDDerivedMesh.
-*
-* BKE_cdderivedmesh.h contains the function prototypes for this file.
-*
-*/
+ * $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) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Ben Batt <benbatt@gmail.com>
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ * Implementation of CDDerivedMesh.
+ *
+ * BKE_cdderivedmesh.h contains the function prototypes for this file.
+ *
+ */
/** \file blender/blenkernel/intern/cdderivedmesh.c
* \ingroup bke
*/
-
+
#include "GL/glew.h"
#include "BLI_blenlib.h"
@@ -756,9 +756,10 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
unsigned char *colors = MEM_mallocN(dm->getNumFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common");
for( i=0; i < dm->getNumFaces(dm); i++ ) {
for( j=0; j < 4; j++ ) {
- colors[i*12+j*3] = col[i*4+j].r;
+ /* bgr -> rgb is intentional (and stupid), but how its stored internally */
+ colors[i*12+j*3] = col[i*4+j].b;
colors[i*12+j*3+1] = col[i*4+j].g;
- colors[i*12+j*3+2] = col[i*4+j].b;
+ colors[i*12+j*3+2] = col[i*4+j].r;
}
}
GPU_color3_upload(dm,colors);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 3a86389dba7..1ec573c853a 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -741,7 +741,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
MDeformVert *dvert = NULL;
Cloth *clothObj = NULL;
int numverts;
- float goalfac = 0;
+ /* float goalfac = 0; */ /* UNUSED */
ClothVertex *verts = NULL;
if (!clmd || !dm) return;
@@ -764,7 +764,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
if (( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_mass-1)) && (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ))
{
verts->goal = dvert->dw [j].weight;
- goalfac= 1.0f;
+ /* goalfac= 1.0f; */ /* UNUSED */
/*
// Kicking goal factor to simplify things...who uses that anyway?
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index d8b51973948..26ee62e035b 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1374,7 +1374,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTree
return collpair;
}
-static void machine_epsilon_offset(Cloth *cloth) {
+static void machine_epsilon_offset(Cloth *cloth)
+{
ClothVertex *cv;
int i, j;
@@ -2363,7 +2364,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
{
Cloth *cloth= clmd->clothObject;
BVHTree *cloth_bvh= cloth->bvhtree;
- unsigned int i=0, numfaces = 0, numverts = 0, k, l, j;
+ unsigned int i=0, /* numfaces = 0, */ /* UNUSED */ numverts = 0, k, l, j;
int rounds = 0; // result counts applied collisions; ic is for debug output;
ClothVertex *verts = NULL;
int ret = 0, ret2 = 0;
@@ -2374,7 +2375,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
return 0;
verts = cloth->verts;
- numfaces = cloth->numfaces;
+ /* numfaces = cloth->numfaces; */ /* UNUSED */
numverts = cloth->numverts;
////////////////////////////////////////////////////////////
@@ -2476,7 +2477,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
// collisions = 1;
verts = cloth->verts; // needed for openMP
- numfaces = cloth->numfaces;
+ /* numfaces = cloth->numfaces; */ /* UNUSED */
numverts = cloth->numverts;
verts = cloth->verts;
diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 61e9daf4138..83003809a37 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -1,4 +1,4 @@
-/*
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -361,72 +361,68 @@ void curvemap_sethandle(CurveMap *cuma, int type)
static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *next, int UNUSED(mode))
{
float *p1,*p2,*p3,pt[3];
- float dx1,dy1, dx,dy, vx,vy, len,len1,len2;
-
- if(bezt->h1==0 && bezt->h2==0) return;
+ float len,len_a, len_b;
+ float dvec_a[2], dvec_b[2];
+
+ if(bezt->h1==0 && bezt->h2==0) {
+ return;
+ }
p2= bezt->vec[1];
if(prev==NULL) {
p3= next->vec[1];
- pt[0]= 2*p2[0]- p3[0];
- pt[1]= 2*p2[1]- p3[1];
+ pt[0]= 2.0f*p2[0] - p3[0];
+ pt[1]= 2.0f*p2[1] - p3[1];
p1= pt;
}
- else p1= prev->vec[1];
+ else {
+ p1= prev->vec[1];
+ }
if(next==NULL) {
p1= prev->vec[1];
- pt[0]= 2*p2[0]- p1[0];
- pt[1]= 2*p2[1]- p1[1];
+ pt[0]= 2.0f*p2[0] - p1[0];
+ pt[1]= 2.0f*p2[1] - p1[1];
p3= pt;
}
- else p3= next->vec[1];
-
- dx= p2[0]- p1[0];
- dy= p2[1]- p1[1];
+ else {
+ p3= next->vec[1];
+ }
- len1= (float)sqrt(dx*dx+dy*dy);
-
- dx1= p3[0]- p2[0];
- dy1= p3[1]- p2[1];
+ sub_v2_v2v2(dvec_a, p2, p1);
+ sub_v2_v2v2(dvec_b, p3, p2);
- len2= (float)sqrt(dx1*dx1+dy1*dy1);
-
- if(len1==0.0f) len1=1.0f;
- if(len2==0.0f) len2=1.0f;
-
- if(bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */
- vx= dx1/len2 + dx/len1;
- vy= dy1/len2 + dy/len1;
-
- len= 2.5614f*(float)sqrt(vx*vx + vy*vy);
+ len_a= len_v2(dvec_a);
+ len_b= len_v2(dvec_b);
+
+ if(len_a==0.0f) len_a=1.0f;
+ if(len_b==0.0f) len_b=1.0f;
+
+ if(bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */
+ float tvec[2];
+ tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a;
+ tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a;
+
+ len= len_v2(tvec) * 2.5614f;
if(len!=0.0f) {
if(bezt->h1==HD_AUTO) {
- len1/=len;
- *(p2-3)= *p2-vx*len1;
- *(p2-2)= *(p2+1)-vy*len1;
+ len_a/=len;
+ madd_v2_v2v2fl(p2-3, p2, tvec, -len_a);
}
if(bezt->h2==HD_AUTO) {
- len2/=len;
- *(p2+3)= *p2+vx*len2;
- *(p2+4)= *(p2+1)+vy*len2;
+ len_b/=len;
+ madd_v2_v2v2fl(p2+3, p2, tvec, len_b);
}
}
}
if(bezt->h1==HD_VECT) { /* vector */
- dx/=3.0f;
- dy/=3.0f;
- *(p2-3)= *p2-dx;
- *(p2-2)= *(p2+1)-dy;
+ madd_v2_v2v2fl(p2-3, p2, dvec_a, -1.0f/3.0f);
}
if(bezt->h2==HD_VECT) {
- dx1/=3.0f;
- dy1/=3.0f;
- *(p2+3)= *p2+dx1;
- *(p2+4)= *(p2+1)+dy1;
+ madd_v2_v2v2fl(p2+3, p2, dvec_b, 1.0f/3.0f);
}
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index a59092784dd..591e0b6a8d2 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -3937,7 +3939,8 @@ static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES];
static short CTI_INIT= 1; /* when non-zero, the list needs to be updated */
/* This function only gets called when CTI_INIT is non-zero */
-static void constraints_init_typeinfo (void) {
+static void constraints_init_typeinfo (void)
+{
constraintsTypeInfo[0]= NULL; /* 'Null' Constraint */
constraintsTypeInfo[1]= &CTI_CHILDOF; /* ChildOf Constraint */
constraintsTypeInfo[2]= &CTI_TRACKTO; /* TrackTo Constraint */
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 794006e6f39..2e9ad11c6ca 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -1,7 +1,4 @@
-
-/* curve.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -2457,72 +2454,77 @@ void makeBevelList(Object *ob)
void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
{
float *p1,*p2,*p3, pt[3];
- float dx1,dy1,dz1,dx,dy,dz,vx,vy,vz,len,len1,len2;
+ float dvec_a[3], dvec_b[3];
+ float len, len_a, len_b;
const float eps= 1e-5;
- if(bezt->h1==0 && bezt->h2==0) return;
+ if(bezt->h1==0 && bezt->h2==0) {
+ return;
+ }
p2= bezt->vec[1];
if(prev==NULL) {
p3= next->vec[1];
- pt[0]= 2*p2[0]- p3[0];
- pt[1]= 2*p2[1]- p3[1];
- pt[2]= 2*p2[2]- p3[2];
+ pt[0]= 2.0f*p2[0] - p3[0];
+ pt[1]= 2.0f*p2[1] - p3[1];
+ pt[2]= 2.0f*p2[2] - p3[2];
p1= pt;
}
- else p1= prev->vec[1];
+ else {
+ p1= prev->vec[1];
+ }
if(next==NULL) {
- pt[0]= 2*p2[0]- p1[0];
- pt[1]= 2*p2[1]- p1[1];
- pt[2]= 2*p2[2]- p1[2];
+ pt[0]= 2.0f*p2[0] - p1[0];
+ pt[1]= 2.0f*p2[1] - p1[1];
+ pt[2]= 2.0f*p2[2] - p1[2];
p3= pt;
}
- else p3= next->vec[1];
+ else {
+ p3= next->vec[1];
+ }
- dx= p2[0]- p1[0];
- dy= p2[1]- p1[1];
- dz= p2[2]- p1[2];
-
- if(mode) len1= dx;
- else len1= (float)sqrt(dx*dx+dy*dy+dz*dz);
-
- dx1= p3[0]- p2[0];
- dy1= p3[1]- p2[1];
- dz1= p3[2]- p2[2];
-
- if(mode) len2= dx1;
- else len2= (float)sqrt(dx1*dx1+dy1*dy1+dz1*dz1);
+ sub_v3_v3v3(dvec_a, p2, p1);
+ sub_v3_v3v3(dvec_b, p3, p2);
- if(len1==0.0f) len1=1.0f;
- if(len2==0.0f) len2=1.0f;
+ if (mode != 0) {
+ len_a= dvec_a[0];
+ len_b= dvec_b[0];
+ }
+ else {
+ len_a= len_v3(dvec_a);
+ len_b= len_v3(dvec_b);
+ }
+
+ if(len_a==0.0f) len_a=1.0f;
+ if(len_b==0.0f) len_b=1.0f;
if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) || ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { /* auto */
- vx= dx1/len2 + dx/len1;
- vy= dy1/len2 + dy/len1;
- vz= dz1/len2 + dz/len1;
- len= 2.5614f*(float)sqrt(vx*vx + vy*vy + vz*vz);
+ float tvec[3];
+ tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a;
+ tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a;
+ tvec[2]= dvec_b[2]/len_b + dvec_a[2]/len_a;
+ len= len_v3(tvec) * 2.5614f;
+
if(len!=0.0f) {
int leftviolate=0, rightviolate=0; /* for mode==2 */
- if(len1>5.0f*len2) len1= 5.0f*len2;
- if(len2>5.0f*len1) len2= 5.0f*len1;
+ if(len_a>5.0f*len_b) len_a= 5.0f*len_b;
+ if(len_b>5.0f*len_a) len_b= 5.0f*len_a;
if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM)) {
- len1/=len;
- *(p2-3)= *p2-vx*len1;
- *(p2-2)= *(p2+1)-vy*len1;
- *(p2-1)= *(p2+2)-vz*len1;
+ len_a/=len;
+ madd_v3_v3v3fl(p2-3, p2, tvec, -len_a);
- if((bezt->h1==HD_AUTO_ANIM) && next && prev) { // keep horizontal if extrema
+ if((bezt->h1==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */
float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
float ydiff2= next->vec[1][1] - bezt->vec[1][1];
if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[0][1]= bezt->vec[1][1];
}
- else { // handles should not be beyond y coord of two others
+ else { /* handles should not be beyond y coord of two others */
if(ydiff1 <= 0.0f) {
if(prev->vec[1][1] > bezt->vec[0][1]) {
bezt->vec[0][1]= prev->vec[1][1];
@@ -2539,18 +2541,16 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
}
}
if(ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) {
- len2/=len;
- *(p2+3)= *p2+vx*len2;
- *(p2+4)= *(p2+1)+vy*len2;
- *(p2+5)= *(p2+2)+vz*len2;
+ len_b/=len;
+ madd_v3_v3v3fl(p2+3, p2, tvec, len_b);
- if((bezt->h2==HD_AUTO_ANIM) && next && prev) { // keep horizontal if extrema
+ if((bezt->h2==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */
float ydiff1= prev->vec[1][1] - bezt->vec[1][1];
float ydiff2= next->vec[1][1] - bezt->vec[1][1];
if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) {
bezt->vec[2][1]= bezt->vec[1][1];
}
- else { // handles should not be beyond y coord of two others
+ else { /* andles should not be beyond y coord of two others */
if(ydiff1 <= 0.0f) {
if(next->vec[1][1] < bezt->vec[2][1]) {
bezt->vec[2][1]= next->vec[1][1];
@@ -2566,25 +2566,25 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
}
}
}
- if(leftviolate || rightviolate) { /* align left handle */
+ if(leftviolate || rightviolate) { /* align left handle */
float h1[3], h2[3];
+ float dot;
sub_v3_v3v3(h1, p2-3, p2);
sub_v3_v3v3(h2, p2, p2+3);
- len1= normalize_v3(h1);
- len2= normalize_v3(h2);
- vz= dot_v3v3(h1, h2);
+ len_a= normalize_v3(h1);
+ len_b= normalize_v3(h2);
+
+ dot= dot_v3v3(h1, h2);
if(leftviolate) {
- *(p2+3)= *(p2) - vz*len2*h1[0];
- *(p2+4)= *(p2+1) - vz*len2*h1[1];
- *(p2+5)= *(p2+2) - vz*len2*h1[2];
+ mul_v3_fl(h1, dot * len_b);
+ sub_v3_v3v3(p2+3, p2, h1);
}
else {
- *(p2-3)= *(p2) + vz*len1*h2[0];
- *(p2-2)= *(p2+1) + vz*len1*h2[1];
- *(p2-1)= *(p2+2) + vz*len1*h2[2];
+ mul_v3_fl(h2, dot * len_a);
+ add_v3_v3v3(p2-3, p2, h2);
}
}
@@ -2592,60 +2592,50 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
}
if(bezt->h1==HD_VECT) { /* vector */
- dx/=3.0f;
- dy/=3.0f;
- dz/=3.0f;
- *(p2-3)= *p2-dx;
- *(p2-2)= *(p2+1)-dy;
- *(p2-1)= *(p2+2)-dz;
+ madd_v3_v3v3fl(p2-3, p2, dvec_a, -1.0f/3.0f);
}
if(bezt->h2==HD_VECT) {
- dx1/=3.0f;
- dy1/=3.0f;
- dz1/=3.0f;
- *(p2+3)= *p2+dx1;
- *(p2+4)= *(p2+1)+dy1;
- *(p2+5)= *(p2+2)+dz1;
+ madd_v3_v3v3fl(p2+3, p2, dvec_b, 1.0f/3.0f);
}
- len2= len_v3v3(p2, p2+3);
- len1= len_v3v3(p2, p2-3);
- if(len1==0.0f) len1= 1.0f;
- if(len2==0.0f) len2= 1.0f;
+ len_b= len_v3v3(p2, p2+3);
+ len_a= len_v3v3(p2, p2-3);
+ if(len_a==0.0f) len_a= 1.0f;
+ if(len_b==0.0f) len_b= 1.0f;
if(bezt->f1 & SELECT) { /* order of calculation */
- if(bezt->h2==HD_ALIGN) { /* aligned */
- if(len1>eps) {
- len= len2/len1;
- p2[3]= p2[0]+len*(p2[0]-p2[-3]);
- p2[4]= p2[1]+len*(p2[1]-p2[-2]);
- p2[5]= p2[2]+len*(p2[2]-p2[-1]);
+ if(bezt->h2==HD_ALIGN) { /* aligned */
+ if(len_a>eps) {
+ len= len_b/len_a;
+ p2[3]= p2[0]+len*(p2[0] - p2[-3]);
+ p2[4]= p2[1]+len*(p2[1] - p2[-2]);
+ p2[5]= p2[2]+len*(p2[2] - p2[-1]);
}
}
if(bezt->h1==HD_ALIGN) {
- if(len2>eps) {
- len= len1/len2;
- p2[-3]= p2[0]+len*(p2[0]-p2[3]);
- p2[-2]= p2[1]+len*(p2[1]-p2[4]);
- p2[-1]= p2[2]+len*(p2[2]-p2[5]);
+ if(len_b>eps) {
+ len= len_a/len_b;
+ p2[-3]= p2[0]+len*(p2[0] - p2[3]);
+ p2[-2]= p2[1]+len*(p2[1] - p2[4]);
+ p2[-1]= p2[2]+len*(p2[2] - p2[5]);
}
}
}
else {
if(bezt->h1==HD_ALIGN) {
- if(len2>eps) {
- len= len1/len2;
- p2[-3]= p2[0]+len*(p2[0]-p2[3]);
- p2[-2]= p2[1]+len*(p2[1]-p2[4]);
- p2[-1]= p2[2]+len*(p2[2]-p2[5]);
+ if(len_b>eps) {
+ len= len_a/len_b;
+ p2[-3]= p2[0]+len*(p2[0] - p2[3]);
+ p2[-2]= p2[1]+len*(p2[1] - p2[4]);
+ p2[-1]= p2[2]+len*(p2[2] - p2[5]);
}
}
if(bezt->h2==HD_ALIGN) { /* aligned */
- if(len1>eps) {
- len= len2/len1;
- p2[3]= p2[0]+len*(p2[0]-p2[-3]);
- p2[4]= p2[1]+len*(p2[1]-p2[-2]);
- p2[5]= p2[2]+len*(p2[2]-p2[-1]);
+ if(len_a>eps) {
+ len= len_b/len_a;
+ p2[3]= p2[0]+len*(p2[0] - p2[-3]);
+ p2[4]= p2[1]+len*(p2[1] - p2[-2]);
+ p2[5]= p2[2]+len*(p2[2] - p2[-1]);
}
}
}
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 30da2e01011..7d98119610b 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1,36 +1,36 @@
/*
-* $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) 2006 Blender Foundation.
-* All rights reserved.
-*
-* The Original Code is: all of this file.
-*
-* Contributor(s): Ben Batt <benbatt@gmail.com>
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-* Implementation of CustomData.
-*
-* BKE_customdata.h contains the function prototypes for this file.
-*
-*/
+ * $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) 2006 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Ben Batt <benbatt@gmail.com>
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ * Implementation of CustomData.
+ *
+ * BKE_customdata.h contains the function prototypes for this file.
+ *
+ */
/** \file blender/blenkernel/intern/customdata.c
* \ingroup bke
@@ -2383,10 +2383,8 @@ int CustomData_verify_versions(struct CustomData *data, int index)
static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external)
{
- char *path = (id->lib)? id->lib->filepath: G.main->name;
-
BLI_strncpy(filename, external->filename, FILE_MAX);
- BLI_path_abs(filename, path);
+ BLI_path_abs(filename, ID_BLEND_PATH(G.main, id));
}
void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem)
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 11a0a5884ee..f18f533d460 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -1,9 +1,4 @@
-/* deform.c June 2001
- *
- * support for deformation groups
- *
- * Reevan McKay
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -27,7 +22,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Reevan McKay
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 6f27a104144..80a40c0a3a3 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2028,17 +2028,27 @@ static int object_modifiers_use_time(Object *ob)
/* check whether any modifiers are animated */
if (ob->adt) {
AnimData *adt = ob->adt;
+ FCurve *fcu;
/* action - check for F-Curves with paths containing 'modifiers[' */
if (adt->action) {
- FCurve *fcu;
-
for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
if (fcu->rna_path && strstr(fcu->rna_path, "modifiers["))
return 1;
}
}
+ /* This here allows modifier properties to get driven and still update properly
+ *
+ * Workaround to get [#26764] (e.g. subsurf levels not updating when animated/driven)
+ * working, without the updating problems ([#28525] [#28690] [#28774] [#28777]) caused
+ * by the RNA updates cache introduced in r.38649
+ */
+ for (fcu = adt->drivers.first; fcu; fcu = fcu->next) {
+ if (fcu->rna_path && strstr(fcu->rna_path, "modifiers["))
+ return 1;
+ }
+
// XXX: also, should check NLA strips, though for now assume that nobody uses
// that and we can omit that for performance reasons...
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index b19ea93a1b8..fb67c07cfe9 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1,6 +1,4 @@
-/* displist.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -1207,7 +1205,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if(cu->path) free_path(cu->path);
cu->path= NULL;
- if(ob->type==OB_FONT) BKE_text_to_curve(scene, ob, 0);
+ if(ob->type==OB_FONT) BKE_text_to_curve(G.main, scene, ob, 0);
if(!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts);
@@ -1406,7 +1404,8 @@ void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, stru
}
/* add Orco layer to the displist object which has got derived mesh and return orco */
-float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) {
+float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender)
+{
float *orco;
if (derivedFinal == NULL)
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 7fb9f96e0cf..5ce7b82a45f 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -1,6 +1,4 @@
-/* effect.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 3916d0ca701..e2326b005c1 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -818,7 +820,7 @@ void calchandles_fcurve (FCurve *fcu)
* -> Vector handles: become 'nothing' when (one half selected AND other not)
* - PHASE 2: recalculate handles
*/
-void testhandles_fcurve (FCurve *fcu)
+void testhandles_fcurve (FCurve *fcu, const short use_handle)
{
BezTriple *bezt;
unsigned int a;
@@ -834,9 +836,16 @@ void testhandles_fcurve (FCurve *fcu)
/* flag is initialised as selection status
* of beztriple control-points (labelled 0,1,2)
*/
- if (bezt->f1 & SELECT) flag |= (1<<0); // == 1
if (bezt->f2 & SELECT) flag |= (1<<1); // == 2
- if (bezt->f3 & SELECT) flag |= (1<<2); // == 4
+ if(use_handle == FALSE) {
+ if(flag & 2) {
+ flag |= (1<<0) | (1<<2);
+ }
+ }
+ else {
+ if (bezt->f1 & SELECT) flag |= (1<<0); // == 1
+ if (bezt->f3 & SELECT) flag |= (1<<2); // == 4
+ }
/* one or two handles selected only */
if (ELEM(flag, 0, 7)==0) {
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 95c0aa60991..d5c54893128 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 6898615c753..4c8d0cf998d 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -1,6 +1,4 @@
-/* font.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -284,7 +282,7 @@ struct TmpFont *vfont_find_tmpfont(VFont *vfont)
return tmpfnt;
}
-static VFontData *vfont_get_data(VFont *vfont)
+static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
{
struct TmpFont *tmpfnt = NULL;
PackedFile *tpf;
@@ -319,11 +317,11 @@ static VFontData *vfont_get_data(VFont *vfont)
BLI_addtail(&ttfdata, tmpfnt);
}
} else {
- pf= newPackedFile(NULL, vfont->name);
+ pf= newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
if(!tmpfnt)
{
- tpf= newPackedFile(NULL, vfont->name);
+ tpf= newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id));
// Add temporary packed file to globals
tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font");
@@ -351,7 +349,7 @@ static VFontData *vfont_get_data(VFont *vfont)
return vfont->data;
}
-VFont *load_vfont(const char *name)
+VFont *load_vfont(Main *bmain, const char *name)
{
char filename[FILE_MAXFILE];
VFont *vfont= NULL;
@@ -371,8 +369,8 @@ VFont *load_vfont(const char *name)
BLI_strncpy(dir, name, sizeof(dir));
BLI_splitdirstring(dir, filename);
- pf= newPackedFile(NULL, name);
- tpf= newPackedFile(NULL, name);
+ pf= newPackedFile(NULL, name, bmain->name);
+ tpf= newPackedFile(NULL, name, bmain->name);
is_builtin= 0;
}
@@ -382,7 +380,7 @@ VFont *load_vfont(const char *name)
vfd= BLI_vfontdata_from_freetypefont(pf);
if (vfd) {
- vfont = alloc_libblock(&G.main->vfont, ID_VF, filename);
+ vfont = alloc_libblock(&bmain->vfont, ID_VF, filename);
vfont->data = vfd;
/* if there's a font name, use it for the ID name */
@@ -439,7 +437,7 @@ VFont *get_builtin_font(void)
if (strcmp(vf->name, FO_BUILTIN_NAME)==0)
return vf;
- return load_vfont(FO_BUILTIN_NAME);
+ return load_vfont(G.main, FO_BUILTIN_NAME);
}
static VChar *find_vfont_char(VFontData *vfd, intptr_t character)
@@ -500,7 +498,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i
}
-static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float ofsx, float ofsy, float rot, int charidx)
+static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo *info, float ofsx, float ofsy, float rot, int charidx)
{
BezTriple *bezt1, *bezt2;
Nurb *nu1 = NULL, *nu2 = NULL;
@@ -509,7 +507,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float
VChar *che = NULL;
int i;
- vfd= vfont_get_data(which_vfont(cu, info));
+ vfd= vfont_get_data(bmain, which_vfont(cu, info));
if (!vfd) return;
/*
@@ -662,7 +660,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
}
}
-struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
+struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int mode)
{
VFont *vfont, *oldvfont;
VFontData *vfd= NULL;
@@ -714,7 +712,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
if (cu->tb==NULL)
cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBox compat");
- vfd= vfont_get_data(vfont);
+ vfd= vfont_get_data(bmain, vfont);
/* The VFont Data can not be found */
if(!vfd) {
@@ -792,7 +790,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
}
if (vfont != oldvfont) {
- vfd= vfont_get_data(vfont);
+ vfd= vfont_get_data(bmain, vfont);
oldvfont = vfont;
}
@@ -1157,7 +1155,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode)
}
// We do not want to see any character for \n or \r
if(cha != '\n' && cha != '\r')
- buildchar(cu, cha, info, ct->xof, ct->yof, ct->rot, i);
+ buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i);
if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) {
float ulwidth, uloverlap= 0.0f;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index c2e94cc97db..06ca7b7b509 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -182,7 +184,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
gpl->thickness = 3;
/* auto-name */
- sprintf(gpl->info, "GP_Layer");
+ strcpy(gpl->info, "GP_Layer");
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info));
/* make this one the active one */
diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c
index 9effd25c142..07bb4666134 100644
--- a/source/blender/blenkernel/intern/icons.c
+++ b/source/blender/blenkernel/intern/icons.c
@@ -1,32 +1,32 @@
/*
-* $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) 2006-2007 Blender Foundation.
-* All rights reserved.
-*
-* The Original Code is: all of this file.
-*
-* Contributor(s): none yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-*/
+ * $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) 2006-2007 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
/** \file blender/blenkernel/intern/icons.c
* \ingroup bke
diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c
index 21ea2c1d222..8d5668e241a 100644
--- a/source/blender/blenkernel/intern/idcode.c
+++ b/source/blender/blenkernel/intern/idcode.c
@@ -110,7 +110,8 @@ int BKE_idcode_is_valid(int code)
return idtype_from_code(code)?1:0;
}
-int BKE_idcode_is_linkable(int code) {
+int BKE_idcode_is_linkable(int code)
+{
IDType *idt= idtype_from_code(code);
return idt?(idt->flags&IDTYPE_FLAGS_ISLINKABLE):0;
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index d764826cd47..cf8f96c143a 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1,5 +1,4 @@
-/* image.c
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -1480,7 +1479,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
/* try to repack file */
if(ima->packedfile) {
PackedFile *pf;
- pf = newPackedFile(NULL, ima->name);
+ pf = newPackedFile(NULL, ima->name, ID_BLEND_PATH(G.main, &ima->id));
if (pf) {
freePackedFile(ima->packedfile);
ima->packedfile = pf;
@@ -1653,10 +1652,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame)
BLI_stringdec(name, head, tail, &numlen);
BLI_stringenc(name, head, tail, numlen, frame);
- if(ima->id.lib)
- BLI_path_abs(name, ima->id.lib->filepath);
- else
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id));
flag= IB_rect|IB_multilayer;
if(ima->flag & IMA_DO_PREMUL)
@@ -1768,11 +1764,8 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
char str[FILE_MAX];
BLI_strncpy(str, ima->name, FILE_MAX);
- if(ima->id.lib)
- BLI_path_abs(str, ima->id.lib->filepath);
- else
- BLI_path_abs(str, G.main->name);
-
+ BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id));
+
/* FIXME: make several stream accessible in image editor, too*/
ima->anim = openanim(str, IB_rect, 0);
@@ -1834,10 +1827,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
/* get the right string */
BLI_strncpy(str, ima->name, sizeof(str));
- if(ima->id.lib)
- BLI_path_abs(str, ima->id.lib->filepath);
- else
- BLI_path_abs(str, G.main->name);
+ BLI_path_abs(str, ID_BLEND_PATH(G.main, &ima->id));
/* read ibuf */
ibuf = IMB_loadiffname(str, flag);
@@ -1860,7 +1850,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
/* make packed file for autopack */
if ((ima->packedfile == NULL) && (G.fileflags & G_AUTOPACK))
- ima->packedfile = newPackedFile(NULL, str);
+ ima->packedfile = newPackedFile(NULL, str, ID_BLEND_PATH(G.main, &ima->id));
}
}
else
diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c
index 5b237665290..f4d1ff4241d 100644
--- a/source/blender/blenkernel/intern/image_gen.c
+++ b/source/blender/blenkernel/intern/image_gen.c
@@ -1,5 +1,4 @@
-/* image_gen.c
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 099661f7914..cef3eee8c5e 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -913,7 +913,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
{
// Solves for unknown X in equation AX=B
unsigned int conjgrad_loopcount=0, conjgrad_looplimit=100;
- float conjgrad_epsilon=0.0001f, conjgrad_lasterror=0;
+ float conjgrad_epsilon=0.0001f /* , conjgrad_lasterror=0 */ /* UNUSED */;
lfVector *q, *d, *tmp, *r;
float s, starget, a, s_prev;
unsigned int numverts = lA[0].vcount;
@@ -964,7 +964,7 @@ static int cg_filtered(lfVector *ldV, fmatrix3x3 *lA, lfVector *lB, lfVector *z
conjgrad_loopcount++;
}
- conjgrad_lasterror = s;
+ /* conjgrad_lasterror = s; */ /* UNUSED */
del_lfvector(q);
del_lfvector(d);
@@ -1777,7 +1777,7 @@ int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float
steps = 55;
for (i=0; i<steps; i++) {
for (node=cloth->springs; node; node=node->next) {
- ClothVertex *cv1, *cv2;
+ /* ClothVertex *cv1, *cv2; */ /* UNUSED */
int v1, v2;
float len, c, l, vec[3];
@@ -1786,8 +1786,8 @@ int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float
continue;
v1 = spring->ij; v2 = spring->kl;
- cv1 = cloth->verts + v1;
- cv2 = cloth->verts + v2;
+ /* cv1 = cloth->verts + v1; */ /* UNUSED */
+ /* cv2 = cloth->verts + v2; */ /* UNUSED */
len = len_v3v3(cos[v1], cos[v2]);
sub_v3_v3v3(vec, cos[v1], cos[v2]);
@@ -1827,7 +1827,7 @@ int cloth_calc_helper_forces(Object *UNUSED(ob), ClothModifierData * clmd, float
return 1;
}
int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)
-{
+{
unsigned int i=0;
float step=0.0f, tf=clmd->sim_parms->timescale;
Cloth *cloth = clmd->clothObject;
@@ -1981,7 +1981,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
}
void implicit_set_positions (ClothModifierData *clmd)
-{
+{
Cloth *cloth = clmd->clothObject;
ClothVertex *verts = cloth->verts;
unsigned int numverts = cloth->numverts, i;
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 5acd6c169a0..91f3c7a22ba 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1,4 +1,6 @@
-/*
+/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -317,7 +319,7 @@ static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index)
/* ShapeKey types
* NOTE: as we don't have access to the keyblock where the data comes from (for now),
- * we'll just use numerical indices for now...
+ * we'll just use numerical indices for now...
*/
static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index))
{
@@ -1103,7 +1105,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
agrp->flag = AGRP_SELECTED;
if (muteipo) agrp->flag |= AGRP_MUTED;
- strncpy(agrp->name, grpname, sizeof(agrp->name));
+ BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
BLI_addtail(&tmp_act.groups, agrp);
BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 4b8209ab77e..9e48e691b87 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1,7 +1,4 @@
-
-/* key.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -1445,10 +1442,10 @@ KeyBlock *add_keyblock(Key *key, const char *name)
tot= BLI_countlist(&key->block);
if(name) {
- strncpy(kb->name, name, sizeof(kb->name));
+ BLI_strncpy(kb->name, name, sizeof(kb->name));
} else {
- if(tot==1) strcpy(kb->name, "Basis");
- else sprintf(kb->name, "Key %d", tot-1);
+ if(tot==1) BLI_strncpy(kb->name, "Basis", sizeof(kb->name));
+ else BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", tot-1);
}
BLI_uniquename(&key->block, kb, "Key", '.', offsetof(KeyBlock, name), sizeof(kb->name));
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 094214858f9..cbff9c2337e 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -1,7 +1,4 @@
/*
- * lattice.c
- *
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 841e60e6846..6363512a36a 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -955,9 +955,9 @@ static void get_flags_for_id(ID *id, char *buf)
isnode= ((Tex *)id)->use_nodes;
if (id->us<0)
- sprintf(buf, "-1W ");
+ strcpy(buf, "-1W ");
else if (!id->lib && !isfake && id->us && !isnode)
- sprintf(buf, " ");
+ strcpy(buf, " ");
else if(isnode)
sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
else
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index e2659340a90..538e0c98796 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1,7 +1,4 @@
-
-/* material.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -194,7 +191,7 @@ void init_material(Material *ma)
ma->vol.ms_diff = 1.f;
ma->vol.ms_intensity = 1.f;
- ma->game.flag=0;
+ ma->game.flag = GEMAT_BACKCULL;
ma->game.alpha_blend=0;
ma->game.face_orientation=0;
@@ -724,6 +721,48 @@ void test_object_materials(ID *id)
}
}
+void assign_material_id(ID *id, Material *ma, short act)
+{
+ Material *mao, **matar, ***matarar;
+ short *totcolp;
+
+ if(act>MAXMAT) return;
+ if(act<1) act= 1;
+
+ /* prevent crashing when using accidentally */
+ BLI_assert(id->lib == NULL);
+ if(id->lib) return;
+
+ /* test arraylens */
+
+ totcolp= give_totcolp_id(id);
+ matarar= give_matarar_id(id);
+
+ if(totcolp==NULL || matarar==NULL) return;
+
+ if(act > *totcolp) {
+ matar= MEM_callocN(sizeof(void *)*act, "matarray1");
+
+ if(*totcolp) {
+ memcpy(matar, *matarar, sizeof(void *)*(*totcolp));
+ MEM_freeN(*matarar);
+ }
+
+ *matarar= matar;
+ *totcolp= act;
+ }
+
+ /* in data */
+ mao= (*matarar)[act-1];
+ if(mao) mao->id.us--;
+ (*matarar)[act-1]= ma;
+
+ if(ma)
+ id_us_plus((ID *)ma);
+
+ test_object_materials(id);
+}
+
void assign_material(Object *ob, Material *ma, short act)
{
Material *mao, **matar, ***matarar;
@@ -1284,7 +1323,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, const float c
*g=1.0f;
else
*g = tmp;
-
+
tmp = facm + fac*col[2];
if(tmp <= 0.0f)
*b = 0.0f;
@@ -1773,7 +1812,7 @@ int do_version_tface(Main *main, int fileload)
int flag;
int index;
- /* sometimes mesh has no materials but will need a new one. In those
+ /* sometimes mesh has no materials but will need a new one. In those
* cases we need to ignore the mf->mat_nr and only look at the face
* mode because it can be zero as uninitialized or the 1st created material
*/
@@ -1954,6 +1993,11 @@ int do_version_tface(Main *main, int fileload)
}
}
}
+ /* material is not used by faces with texface
+ * set the default flag - do it only once */
+ else
+ if (fileload)
+ ma->game.flag = GEMAT_BACKCULL;
}
return nowarning;
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 555d35726bc..05d07ddf918 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -1,11 +1,4 @@
-/* mball.c
- *
- * MetaBalls are created from a single Object (with a name without number in it),
- * here the DispList and BoundBox also is located.
- * All objects with the same name (but with a number in it) are added to this.
- *
- * texture coordinates are patched within the displist
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -30,13 +23,18 @@
* Contributor(s): Jiri Hnidek <jiri.hnidek@vslib.cz>.
*
* ***** END GPL LICENSE BLOCK *****
+ *
+ * MetaBalls are created from a single Object (with a name without number in it),
+ * here the DispList and BoundBox also is located.
+ * All objects with the same name (but with a number in it) are added to this.
+ *
+ * texture coordinates are patched within the displist
*/
/** \file blender/blenkernel/intern/mball.c
* \ingroup bke
*/
-
#include <stdio.h>
#include <string.h>
#include <math.h>
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 810e7c285e8..9574c886ccc 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1,8 +1,4 @@
-
-/* mesh.c
- *
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -1606,3 +1602,19 @@ void mesh_translate(Mesh *me, float offset[3], int do_keys)
}
}
}
+
+
+void BKE_mesh_ensure_navmesh(Mesh *me)
+{
+ if (!CustomData_has_layer(&me->fdata, CD_RECAST)) {
+ int i;
+ int numFaces = me->totface;
+ int* recastData;
+ CustomData_add_layer_named(&me->fdata, CD_RECAST, CD_CALLOC, NULL, numFaces, "recastData");
+ recastData = (int*)CustomData_get_layer(&me->fdata, CD_RECAST);
+ for (i=0; i<numFaces; i++) {
+ recastData[i] = i+1;
+ }
+ CustomData_add_layer_named(&me->fdata, CD_RECAST, CD_REFERENCE, recastData, numFaces, "recastData");
+ }
+}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index fe26c0ccd2d..9de75a49998 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -1,38 +1,38 @@
/*
-* $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) 2005 by the Blender Foundation.
-* All rights reserved.
-*
-* Contributor(s): Daniel Dunbar
-* Ton Roosendaal,
-* Ben Batt,
-* Brecht Van Lommel,
-* Campbell Barton
-*
-* ***** END GPL LICENSE BLOCK *****
-*
-* Modifier stack implementation.
-*
-* BKE_modifier.h contains the function prototypes for this file.
-*
-*/
+ * $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) 2005 by the Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Daniel Dunbar
+ * Ton Roosendaal,
+ * Ben Batt,
+ * Brecht Van Lommel,
+ * Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ * Modifier stack implementation.
+ *
+ * BKE_modifier.h contains the function prototypes for this file.
+ *
+ */
/** \file blender/blenkernel/intern/modifier.c
* \ingroup bke
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index cd264c5ddfd..749930d4278 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -1029,7 +1029,7 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp)
int nvert = (mface->v4)? 4: 3;
int newtotdisp = multires_grid_tot[newlvl]*nvert;
int x, y, S;
- float (*disps)[3], (*out)[3], u, v;
+ float (*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */
disps = MEM_callocN(sizeof(float) * 3 * newtotdisp, "multires disps");
diff --git a/source/blender/blenkernel/intern/navmesh_conversion.c b/source/blender/blenkernel/intern/navmesh_conversion.c
index 8a2ec1e5169..f670486484b 100644
--- a/source/blender/blenkernel/intern/navmesh_conversion.c
+++ b/source/blender/blenkernel/intern/navmesh_conversion.c
@@ -1,31 +1,35 @@
-/**
-* $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) 2001-2002 by NaN Holding BV.
-* All rights reserved.
-*
-* The Original Code is: all of this file.
-*
-* Contributor(s): none yet.
-*
-* ***** END GPL LICENSE BLOCK *****
-*/
+/*
+ * $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) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/navmesh_conversion.c
+ * \ingroup bke
+ */
#include <math.h>
#include <stdlib.h>
@@ -328,14 +332,10 @@ struct SortContext
const int* trisToFacesMap;
};
-/* XXX: not thread-safe, but it's called only from modifiers stack
- which isn't threaded. Anyway, better to avoid this in the future */
-static struct SortContext *_qsort_context;
-
-static int compareByData(const void * a, const void * b)
+static int compareByData(void *ctx, const void * a, const void * b)
{
- return ( _qsort_context->recastData[_qsort_context->trisToFacesMap[*(int*)a]] -
- _qsort_context->recastData[_qsort_context->trisToFacesMap[*(int*)b]] );
+ return (((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int*)a]] -
+ ((struct SortContext *)ctx)->recastData[((struct SortContext *)ctx)->trisToFacesMap[*(int*)b]] );
}
int buildNavMeshData(const int nverts, const float* verts,
@@ -367,8 +367,7 @@ int buildNavMeshData(const int nverts, const float* verts,
trisMapping[i]=i;
context.recastData = recastData;
context.trisToFacesMap = trisToFacesMap;
- _qsort_context = &context;
- qsort(trisMapping, ntris, sizeof(int), compareByData);
+ recast_qsort(trisMapping, ntris, sizeof(int), &context, compareByData);
//search first valid triangle - triangle of convex polygon
validTriStart = -1;
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 6ce80342dd6..97347d85deb 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -1,4 +1,6 @@
/*
+ * $Id$
+ *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -1284,16 +1286,16 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip)
if (strip->name[0]==0) {
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* act-clip */
- sprintf(strip->name, "%s", (strip->act)?(strip->act->id.name+2):("<No Action>"));
+ BLI_strncpy(strip->name, (strip->act)?(strip->act->id.name+2):("<No Action>"), sizeof(strip->name));
break;
case NLASTRIP_TYPE_TRANSITION: /* transition */
- sprintf(strip->name, "Transition");
+ BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
break;
case NLASTRIP_TYPE_META: /* meta */
- sprintf(strip->name, "Meta");
+ BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
break;
default:
- sprintf(strip->name, "NLA Strip");
+ BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
break;
}
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 524a63a8a95..f0be3c99f13 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1682,7 +1682,7 @@ void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwid
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));
+ BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
else
ntype->storagename[0] = '\0';
ntype->copystoragefunc = copystoragefunc;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f8669c30809..3e4413cec41 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1,6 +1,4 @@
-/* object.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -1659,7 +1657,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob)
if(ob->matbits) MEM_freeN(ob->matbits);
ob->mat = NULL;
ob->matbits= NULL;
- if ((target->totcol) && (target->mat) && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { //XXX OB_SUPPORT_MATERIAL
+ if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
int i;
ob->colbits = target->colbits;
@@ -2839,7 +2837,8 @@ void object_sculpt_modifiers_changed(Object *ob)
}
}
-float give_timeoffset(Object *ob) {
+float give_timeoffset(Object *ob)
+{
if ((ob->ipoflag & OB_OFFS_PARENTADD) && ob->parent) {
return ob->sf + give_timeoffset(ob->parent);
} else {
@@ -2847,7 +2846,8 @@ float give_timeoffset(Object *ob) {
}
}
-int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, float **rot) {
+int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, float **rot)
+{
if (ob->data==NULL)
return 0;
@@ -3065,6 +3065,79 @@ void object_camera_matrix(
}
+void camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, const short do_clip, const float scale[3],
+ float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3])
+{
+ float facx, facy;
+ float depth;
+
+ /* aspect correcton */
+ if (scene) {
+ float aspx= (float) scene->r.xsch*scene->r.xasp;
+ float aspy= (float) scene->r.ysch*scene->r.yasp;
+
+ if(aspx < aspy) {
+ r_asp[0]= aspx / aspy;
+ r_asp[1]= 1.0;
+ }
+ else {
+ r_asp[0]= 1.0;
+ r_asp[1]= aspy / aspx;
+ }
+ }
+ else {
+ r_asp[0]= 1.0f;
+ r_asp[1]= 1.0f;
+ }
+
+ if(camera->type==CAM_ORTHO) {
+ facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0];
+ facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
+ r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0];
+ r_shift[1]= camera->shifty * camera->ortho_scale * scale[1];
+ depth= do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : - drawsize * camera->ortho_scale * scale[2];
+
+ *r_drawsize= 0.5f * camera->ortho_scale;
+ }
+ else {
+ /* that way it's always visible - clipsta+0.1 */
+ float fac;
+ *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
+
+ if(do_clip) {
+ /* fixed depth, variable size (avoids exceeding clipping range) */
+ depth = -(camera->clipsta + 0.1f);
+ fac = depth / (camera->lens/-16.0f * scale[2]);
+ }
+ else {
+ /* fixed size, variable depth (stays a reasonable size in the 3D view) */
+ depth= *r_drawsize * camera->lens/-16.0f * scale[2];
+ fac= *r_drawsize;
+ }
+
+ facx= fac * r_asp[0] * scale[0];
+ facy= fac * r_asp[1] * scale[1];
+ r_shift[0]= camera->shiftx*fac*2 * scale[0];
+ r_shift[1]= camera->shifty*fac*2 * scale[1];
+ }
+
+ r_vec[0][0]= r_shift[0] + facx; r_vec[0][1]= r_shift[1] + facy; r_vec[0][2]= depth;
+ r_vec[1][0]= r_shift[0] + facx; r_vec[1][1]= r_shift[1] - facy; r_vec[1][2]= depth;
+ r_vec[2][0]= r_shift[0] - facx; r_vec[2][1]= r_shift[1] - facy; r_vec[2][2]= depth;
+ r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth;
+}
+
+void camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3])
+{
+ float dummy_asp[2];
+ float dummy_shift[2];
+ float dummy_drawsize;
+ const float dummy_scale[3]= {1.0f, 1.0f, 1.0f};
+
+ camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale,
+ dummy_asp, dummy_shift, &dummy_drawsize, r_vec);
+}
+
#if 0
static int pc_findindex(ListBase *listbase, int index)
{
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index ed729d819b7..2c8975e9cb4 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -1,6 +1,4 @@
/*
- * blenkernel/packedFile.c - (cleaned up mar-01 nzc)
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -168,7 +166,7 @@ PackedFile *newPackedFileMemory(void *mem, int memlen)
return pf;
}
-PackedFile *newPackedFile(ReportList *reports, const char *filename)
+PackedFile *newPackedFile(ReportList *reports, const char *filename, const char *basepath)
{
PackedFile *pf = NULL;
int file, filelen;
@@ -185,7 +183,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename)
// convert relative filenames to absolute filenames
strcpy(name, filename);
- BLI_path_abs(name, G.main->name);
+ BLI_path_abs(name, basepath);
// open the file
// and create a PackedFile structure
@@ -224,7 +222,7 @@ void packAll(Main *bmain, ReportList *reports)
for(ima=bmain->image.first; ima; ima=ima->id.next) {
if(ima->packedfile == NULL && ima->id.lib==NULL) {
if(ima->source==IMA_SRC_FILE) {
- ima->packedfile = newPackedFile(reports, ima->name);
+ ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id));
}
else if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2);
@@ -234,11 +232,11 @@ void packAll(Main *bmain, ReportList *reports)
for(vf=bmain->vfont.first; vf; vf=vf->id.next)
if(vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0)
- vf->packedfile = newPackedFile(reports, vf->name);
+ vf->packedfile = newPackedFile(reports, vf->name, bmain->name);
for(sound=bmain->sound.first; sound; sound=sound->id.next)
if(sound->packedfile == NULL && sound->id.lib==NULL)
- sound->packedfile = newPackedFile(reports, sound->name);
+ sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 82a2436a010..806a7871948 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1,6 +1,4 @@
-/* particle.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -3488,6 +3486,7 @@ static void default_particle_settings(ParticleSettings *part)
part->totpart= 1000;
part->grid_res= 10;
part->timetweak= 1.0;
+ part->courant_target = 0.2;
part->integrator= PART_INT_MIDPOINT;
part->phystype= PART_PHYS_NEWTON;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index e1ea6e419d3..6b601ed4b1a 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1,6 +1,4 @@
-/* particle_system.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -26,6 +24,9 @@
*
* Contributor(s): Raul Fernandez Hernandez (Farsthary), Stephen Swhitehorn.
*
+ * Adaptive time step
+ * Copyright 2011 AutoCRC
+ *
* ***** END GPL LICENSE BLOCK *****
*/
@@ -2321,6 +2322,10 @@ typedef struct SPHRangeData
float massfac;
int use_size;
+
+ /* Same as SPHData::element_size */
+ float element_size;
+ float flow[3];
} SPHRangeData;
typedef struct SPHData {
ParticleSystem *psys[10];
@@ -2328,12 +2333,17 @@ typedef struct SPHData {
float mass;
EdgeHash *eh;
float *gravity;
+ /* Average distance to neighbours (other particles in the support domain),
+ for calculating the Courant number (adaptive time step). */
+ float element_size;
+ float flow[3];
}SPHData;
static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
{
SPHRangeData *pfr = (SPHRangeData *)userdata;
ParticleData *npa = pfr->npsys->particles + index;
float q;
+ float dist;
if(npa == pfr->pa || squared_dist < FLT_EPSILON)
return;
@@ -2344,12 +2354,16 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
*/
if(pfr->tot_neighbors >= 128)
return;
-
+
pfr->neighbors[pfr->tot_neighbors].index = index;
pfr->neighbors[pfr->tot_neighbors].psys = pfr->npsys;
pfr->tot_neighbors++;
- q = (1.f - sqrtf(squared_dist)/pfr->h) * pfr->massfac;
+ dist = sqrtf(squared_dist);
+ q = (1.f - dist/pfr->h) * pfr->massfac;
+
+ add_v3_v3(pfr->flow, npa->state.vel);
+ pfr->element_size += dist;
if(pfr->use_size)
q *= npa->size;
@@ -2397,6 +2411,8 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
pfr.density = pfr.near_density = 0.f;
pfr.h = h;
pfr.pa = pa;
+ pfr.element_size = fluid->radius;
+ pfr.flow[0] = pfr.flow[1] = pfr.flow[2] = 0.0f;
for(i=0; i<10 && psys[i]; i++) {
pfr.npsys = psys[i];
@@ -2405,6 +2421,14 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
BLI_bvhtree_range_query(psys[i]->bvhtree, state->co, h, sph_density_accum_cb, &pfr);
}
+ if (pfr.tot_neighbors > 0) {
+ pfr.element_size /= pfr.tot_neighbors;
+ mul_v3_fl(pfr.flow, 1.0f / pfr.tot_neighbors);
+ } else {
+ pfr.element_size = MAXFLOAT;
+ }
+ sphdata->element_size = pfr.element_size;
+ VECCOPY(sphdata->flow, pfr.flow);
pressure = stiffness * (pfr.density - rest_density);
near_pressure = stiffness_near_fac * pfr.near_density;
@@ -2471,7 +2495,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
madd_v3_v3fl(force, gravity, fluid->buoyancy * (pfr.density-rest_density));
}
-static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float dfra, float *gravity, EdgeHash *springhash){
+static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float dfra, float *gravity, EdgeHash *springhash, float *element_size, float flow[3]) {
ParticleTarget *pt;
int i;
@@ -2491,6 +2515,7 @@ static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float d
sphdata.gravity = gravity;
sphdata.mass = pa_mass;
sphdata.eh = springhash;
+ //sphdata.element_size and sphdata.flow are set in the callback.
/* restore previous state and treat gravity & effectors as external acceleration*/
sub_v3_v3v3(effector_acceleration, pa->state.vel, pa->prev_state.vel);
@@ -2499,6 +2524,8 @@ static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float d
copy_particle_key(&pa->state, &pa->prev_state, 0);
integrate_particle(part, pa, dtime, effector_acceleration, sph_force_cb, &sphdata);
+ *element_size = sphdata.element_size;
+ VECCOPY(flow, sphdata.flow);
}
/************************************************/
@@ -3582,6 +3609,49 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra)){
root->co[0] = root->co[1] = root->co[2] = 0.0f;
}
}
+
+/* Code for an adaptive time step based on the Courant-Friedrichs-Lewy
+ condition. */
+#define MIN_TIMESTEP 1.0f / 101.0f
+/* Tolerance of 1.5 means the last subframe neither favours growing nor
+ shrinking (e.g if it were 1.3, the last subframe would tend to be too
+ small). */
+#define TIMESTEP_EXPANSION_TOLERANCE 1.5f
+
+/* Calculate the speed of the particle relative to the local scale of the
+ simulation. This should be called once per particle during a simulation
+ step, after the velocity has been updated. element_size defines the scale of
+ the simulation, and is typically the distance to neighbourning particles. */
+void update_courant_num(ParticleSimulationData *sim, ParticleData *pa,
+ float dtime, float element_size, float flow[3])
+{
+ float relative_vel[3];
+ float speed;
+
+ sub_v3_v3v3(relative_vel, pa->state.vel, flow);
+ speed = len_v3(relative_vel);
+ if (sim->courant_num < speed * dtime / element_size)
+ sim->courant_num = speed * dtime / element_size;
+}
+/* Update time step size to suit current conditions. */
+float update_timestep(ParticleSystem *psys, ParticleSimulationData *sim,
+ float t_frac)
+{
+ if (sim->courant_num == 0.0f)
+ psys->dt_frac = 1.0f;
+ else
+ psys->dt_frac *= (psys->part->courant_target / sim->courant_num);
+ CLAMP(psys->dt_frac, MIN_TIMESTEP, 1.0f);
+
+ /* Sync with frame end if it's close. */
+ if (t_frac == 1.0f)
+ return psys->dt_frac;
+ else if (t_frac + (psys->dt_frac * TIMESTEP_EXPANSION_TOLERANCE) >= 1.0f)
+ return 1.0f - t_frac;
+ else
+ return psys->dt_frac;
+}
+
/************************************************/
/* System Core */
/************************************************/
@@ -3597,7 +3667,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
/* frame & time changes */
float dfra, dtime;
float birthtime, dietime;
-
+
/* where have we gone in time since last time */
dfra= cfra - psys->cfra;
@@ -3735,6 +3805,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
{
EdgeHash *springhash = sph_springhash_build(psys);
float *gravity = NULL;
+ float element_size, flow[3];
if(psys_uses_gravity(sim))
gravity = sim->scene->physics_settings.gravity;
@@ -3744,13 +3815,17 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
basic_integrate(sim, p, pa->state.time, cfra);
/* actual fluids calculations */
- sph_integrate(sim, pa, pa->state.time, gravity, springhash);
+ sph_integrate(sim, pa, pa->state.time, gravity, springhash,
+ &element_size, flow);
if(sim->colliders)
collision_check(sim, p, pa->state.time, cfra);
/* SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */
basic_rotate(part, pa, pa->state.time, timestep);
+
+ if (part->time_flag & PART_TIME_AUTOSF)
+ update_courant_num(sim, pa, dtime, element_size, flow);
}
sph_springs_modify(psys, timestep);
@@ -3952,6 +4027,7 @@ static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNU
return totpart - oldtotpart;
}
+
/* Calculates the next state for all particles of the system
* In particles code most fra-ending are frames, time-ending are fra*timestep (seconds)
* 1. Emit particles
@@ -4057,23 +4133,39 @@ static void system_step(ParticleSimulationData *sim, float cfra)
}
if(psys->totpart) {
- int dframe, subframe = 0, totframesback = 0, totsubframe = part->subframes+1;
- float fraction;
-
+ int dframe, totframesback = 0;
+ float t_frac, dt_frac;
+
/* handle negative frame start at the first frame by doing
* all the steps before the first frame */
if((int)cfra == startframe && part->sta < startframe)
totframesback = (startframe - (int)part->sta);
-
+
+ if (!(part->time_flag & PART_TIME_AUTOSF)) {
+ /* Constant time step */
+ psys->dt_frac = 1.0f / (float) (part->subframes + 1);
+ } else if ((int)cfra == startframe) {
+ /* Variable time step; use a very conservative value at the start.
+ * If it doesn't need to be so small, it will quickly grow. */
+ psys->dt_frac = 1.0;
+ } else if (psys->dt_frac < MIN_TIMESTEP) {
+ psys->dt_frac = MIN_TIMESTEP;
+ }
+
for(dframe=-totframesback; dframe<=0; dframe++) {
- /* ok now we're all set so let's go */
- for (subframe = 1; subframe <= totsubframe; subframe++) {
- fraction = (float)subframe/(float)totsubframe;
- dynamics_step(sim, cfra+dframe+fraction - 1.f);
- psys->cfra = cfra+dframe+fraction - 1.f;
+ /* simulate each subframe */
+ dt_frac = psys->dt_frac;
+ for (t_frac = dt_frac; t_frac <= 1.0f; t_frac += dt_frac) {
+ sim->courant_num = 0.0f;
+ dynamics_step(sim, cfra+dframe+t_frac - 1.f);
+ psys->cfra = cfra+dframe+t_frac - 1.f;
+#if 0
+ printf("%f,%f,%f,%f\n", cfra+dframe+t_frac - 1.f, t_frac, dt_frac, sim->courant_num);
+#endif
+ if (part->time_flag & PART_TIME_AUTOSF)
+ dt_frac = update_timestep(psys, sim, t_frac);
}
}
-
}
/* 4. only write cache starting from second frame */
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index a56010a5ccf..fb69db17b97 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -2544,7 +2544,8 @@ static void ptcache_dt_to_str(char *str, double dtime)
sprintf(str, "%is", ((int)dtime) % 60);
}
-static void *ptcache_bake_thread(void *ptr) {
+static void *ptcache_bake_thread(void *ptr)
+{
int usetimer = 0, sfra, efra;
double stime, ptime, ctime, fetd;
char run[32], cur[32], etd[32];
diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c
index d0e4832889b..cdf2e39a4dd 100644
--- a/source/blender/blenkernel/intern/property.c
+++ b/source/blender/blenkernel/intern/property.c
@@ -1,7 +1,4 @@
-
-/* property.c june 2000
- *
- * ton roosendaal
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -25,7 +22,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): ton roosendaal
*
* ***** END GPL LICENSE BLOCK *****
*/
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index d529a6d94c9..a75a075dfc1 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -641,6 +641,8 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
bMessageActuator *ma;
bParentActuator *para;
bArmatureActuator *aa;
+ bSteeringActuator *sta;
+
sens= obt->sensors.first;
while(sens) {
@@ -688,6 +690,10 @@ void sca_remove_ob_poin(Object *obt, Object *ob)
if (aa->target == ob) aa->target = NULL;
if (aa->subtarget == ob) aa->subtarget = NULL;
break;
+ case ACT_STEERING:
+ sta = act->data;
+ if (sta->navmesh == ob) sta->navmesh = NULL;
+ if (sta->target == ob) sta->target = NULL;
}
act= act->next;
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 628cd3cfe6a..dfbb0f6318a 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1,6 +1,4 @@
-/* scene.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -56,6 +54,7 @@
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_callbacks.h"
#include "BKE_anim.h"
#include "BKE_animsys.h"
@@ -435,7 +434,7 @@ Scene *add_scene(const char *name)
sce->toolsettings->skgen_resolution = 100;
sce->toolsettings->skgen_threshold_internal = 0.01f;
sce->toolsettings->skgen_threshold_external = 0.01f;
- sce->toolsettings->skgen_angle_limit = 45.0f;
+ sce->toolsettings->skgen_angle_limit = 45.0f;
sce->toolsettings->skgen_length_ratio = 1.3f;
sce->toolsettings->skgen_length_limit = 1.5f;
sce->toolsettings->skgen_correlation_limit = 0.98f;
@@ -532,7 +531,7 @@ Scene *add_scene(const char *name)
sce->gm.recastData.agentradius = 0.6f;
sce->gm.recastData.edgemaxlen = 12.0f;
sce->gm.recastData.edgemaxerror = 1.3f;
- sce->gm.recastData.regionminsize = 50.f;
+ sce->gm.recastData.regionminsize = 8.f;
sce->gm.recastData.regionmergesize = 20.f;
sce->gm.recastData.vertsperpoly = 6;
sce->gm.recastData.detailsampledist = 6.0f;
@@ -1029,6 +1028,9 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
float ctime = BKE_curframe(sce);
Scene *sce_iter;
+ /* keep this first */
+ BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_PRE);
+
sound_set_cfra(sce->r.cfra);
/* clear animation overrides */
@@ -1055,6 +1057,9 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay)
/* object_handle_update() on all objects, groups and sets */
scene_update_tagged_recursive(bmain, sce, sce);
+
+ /* keep this last */
+ BLI_exec_cb(bmain, (ID *)sce, BLI_CB_EVT_FRAME_CHANGE_POST);
}
/* return default layer, also used to patch old files */
diff --git a/source/blender/blenkernel/intern/script.c b/source/blender/blenkernel/intern/script.c
index 77153fc37ba..77a79a6c8a4 100644
--- a/source/blender/blenkernel/intern/script.c
+++ b/source/blender/blenkernel/intern/script.c
@@ -1,10 +1,6 @@
-/* blenkernel/script.c
- *
- *
+/*
* $Id$
*
- * Function(s) related to struct script management.
- *
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index 00f88fb6202..88e9d9209d4 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -1,5 +1,5 @@
/*
-* $Id$
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index e5d74177c91..d8d6ed6ea6d 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -41,6 +41,7 @@
#include "BLI_math.h" /* windows needs for M_PI */
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
@@ -177,7 +178,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
MEM_freeN(info);
cp= BLI_dynlib_find_symbol(pis->handle, "seqname");
- if(cp) strncpy(cp, seqname, 21);
+ if(cp) BLI_strncpy(cp, seqname, 21);
} else {
printf ("Plugin returned unrecognized version number\n");
return;
@@ -203,7 +204,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq");
- strncpy(pis->name, str, FILE_MAXDIR+FILE_MAXFILE);
+ BLI_strncpy(pis->name, str, FILE_MAX);
open_plugin_seq(pis, seqname);
if(pis->doit==NULL) {
@@ -1638,8 +1639,6 @@ float hyp3,hyp4,b4,b5
if(wipezone->flip) x = xo - x;
angle = wipezone->angle;
- posy = facf0 * yo;
-
if(wipe->forward){
posx = facf0 * xo;
posy = facf0 * yo;
@@ -2319,7 +2318,7 @@ static void RVBlurBitmap2_byte ( unsigned char* map, int width,int height,
/* Swap buffers */
- swap=temp;temp=map;map=swap;
+ swap=temp;temp=map; /* map=swap; */ /* UNUSED */
/* Tidy up */
MEM_freeN (filter);
@@ -2489,7 +2488,7 @@ static void RVBlurBitmap2_float ( float* map, int width,int height,
/* Swap buffers */
- swap=temp;temp=map;map=swap;
+ swap=temp;temp=map; /* map=swap; */ /* UNUSED */
/* Tidy up */
MEM_freeN (filter);
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index a3237da6234..5a2c53f5b9b 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -1,5 +1,5 @@
/*
-* $Id$
+ * $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -2852,7 +2852,8 @@ void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_ch
left and right are the bounds at which the sequence is rendered,
start and end are from the start and fixed length of the sequence.
*/
-int seq_tx_get_start(Sequence *seq) {
+int seq_tx_get_start(Sequence *seq)
+{
return seq->start;
}
int seq_tx_get_end(Sequence *seq)
@@ -3653,7 +3654,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
calc_sequence_disp(scene, seq);
/* last active name */
- strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR);
seq_load_apply(scene, seq, seq_load);
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
index 432dc9ec609..a5afc0afda1 100644
--- a/source/blender/blenkernel/intern/sketch.c
+++ b/source/blender/blenkernel/intern/sketch.c
@@ -1,5 +1,4 @@
/*
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 6ab1574ca80..85140841f15 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -1,6 +1,4 @@
/*
- * smoke.c
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c
index 2960d8a41e5..88f72c33802 100644
--- a/source/blender/blenkernel/intern/softbody.c
+++ b/source/blender/blenkernel/intern/softbody.c
@@ -1,5 +1,4 @@
-/* softbody.c
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -1744,12 +1743,12 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
GHash *hash;
GHashIterator *ihash;
float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3],d_nvect[3], dv1[3],ve[3],avel[3]={0.0,0.0,0.0},
- vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f,
- outerforceaccu[3],innerforceaccu[3],
- facedist,n_mag,force_mag_norm,minx,miny,minz,maxx,maxy,maxz,
- innerfacethickness = -0.5f, outerfacethickness = 0.2f,
- ee = 5.0f, ff = 0.1f, fa=1;
- int a, deflected=0, cavel=0,ci=0;
+ vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f,
+ outerforceaccu[3], innerforceaccu[3],
+ facedist, /* n_mag, */ /* UNUSED */ force_mag_norm, minx, miny, minz, maxx, maxy, maxz,
+ innerfacethickness = -0.5f, outerfacethickness = 0.2f,
+ ee = 5.0f, ff = 0.1f, fa=1;
+ int a, deflected=0, cavel=0, ci=0;
/* init */
*intrusion = 0.0f;
hash = vertexowner->soft->scratch->colliderhash;
@@ -1869,7 +1868,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
VECSUB(dv1,opco,nv2); /* abuse dv1 to have vertex in question at *origin* of triangle */
cross_v3_v3v3(d_nvect, edge2, edge1);
- n_mag = normalize_v3(d_nvect);
+ /* n_mag = */ /* UNUSED */ normalize_v3(d_nvect);
facedist = dot_v3v3(dv1,d_nvect);
// so rules are
//
@@ -1906,7 +1905,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3],
VECSUB(dv1,opco,nv4); /* abuse dv1 to have vertex in question at *origin* of triangle */
cross_v3_v3v3(d_nvect, edge2, edge1);
- n_mag = normalize_v3(d_nvect);
+ /* n_mag = */ /* UNUSED */ normalize_v3(d_nvect);
facedist = dot_v3v3(dv1,d_nvect);
if ((facedist > innerfacethickness) && (facedist < outerfacethickness)){
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 73d0d70778f..f2d92154c66 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -340,20 +340,13 @@ void sound_load(struct Main *bmain, struct bSound* sound)
#endif
{
char fullpath[FILE_MAX];
- char *path;
/* load sound */
PackedFile* pf = sound->packedfile;
/* dont modify soundact->sound->name, only change a copy */
BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
-
- if(sound->id.lib)
- path = sound->id.lib->filepath;
- else
- path = bmain->name;
-
- BLI_path_abs(fullpath, path);
+ BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id));
/* but we need a packed file then */
if (pf)
diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c
index 200dbd41899..ae29230423f 100644
--- a/source/blender/blenkernel/intern/speaker.c
+++ b/source/blender/blenkernel/intern/speaker.c
@@ -1,6 +1,4 @@
-/* speaker.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 2c507370288..b5fc76a8551 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -1,6 +1,4 @@
-/* text.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -2792,7 +2790,8 @@ int setcurr_tab_spaces (Text *text, int space)
/*********************************/
/* Creates and adds a marker to the list maintaining sorted order */
-void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags) {
+void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags)
+{
TextMarker *tmp, *marker;
marker= MEM_mallocN(sizeof(TextMarker), "text_marker");
@@ -2841,7 +2840,8 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en
/* Clears all markers on the specified line between two points. If the group or
flags fields are non-zero the returned flag must be in the specified group
and have at least the specified flags set. */
-short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) {
+short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags)
+{
TextMarker *marker, *next;
int lineno= txt_get_span(text->lines.first, line);
short cleared= 0;
@@ -2866,7 +2866,8 @@ short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, in
/* Clears all markers in the specified group (if given) with at least the
specified flags set. Useful for clearing temporary markers (group=0,
flags=TMARK_TEMP) */
-short txt_clear_markers(Text *text, int group, int flags) {
+short txt_clear_markers(Text *text, int group, int flags)
+{
TextMarker *marker, *next;
short cleared= 0;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 38165182d83..d344f79bb6c 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -1,6 +1,4 @@
-/* texture.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -640,7 +638,11 @@ void default_mtex(MTex *mtex)
mtex->size[1]= 1.0;
mtex->size[2]= 1.0;
mtex->tex= NULL;
- mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE;
+
+ /* MTEX_BUMP_FLIPPED is temporary before 2.61 release to prevent flipping normals
+ when creating file in 2.60, opening it in 2.59, saving and opening in 2.60 again */
+ mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE | MTEX_BUMP_FLIPPED;
+
mtex->colormodel= 0;
mtex->r= 1.0;
mtex->g= 0.0;
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index d413177873f..7d278f37cfb 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -1,7 +1,4 @@
-
-/* world.c
- *
- *
+/*
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c
index 769a3f9b11e..b989d44c391 100644
--- a/source/blender/blenkernel/intern/writeavi.c
+++ b/source/blender/blenkernel/intern/writeavi.c
@@ -1,7 +1,4 @@
/*
- * Functions for writing avi-format files.
- * Added interface for generic movie support (ton)
- *
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
@@ -28,7 +25,9 @@
* Contributor(s): Robert Wenzlaff
*
* ***** END GPL LICENSE BLOCK *****
- *
+ *
+ * Functions for writing avi-format files.
+ * Added interface for generic movie support (ton)
*/
/** \file blender/blenkernel/intern/writeavi.c
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index 13875ff19f7..58a2f45e876 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -1,6 +1,3 @@
-/** \file blender/blenkernel/intern/writeffmpeg.c
- * \ingroup bke
- */
/*
* $Id$
*
@@ -20,6 +17,10 @@
*
*/
+/** \file blender/blenkernel/intern/writeffmpeg.c
+ * \ingroup bke
+ */
+
#ifdef WITH_FFMPEG
#include <string.h>
#include <stdio.h>
@@ -489,6 +490,12 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
c->qmax=51;
}
+ // Keep lossless encodes in the RGB domain.
+ if (codec_id == CODEC_ID_HUFFYUV || codec_id == CODEC_ID_FFV1) {
+ /* HUFFYUV was PIX_FMT_YUV422P before */
+ c->pix_fmt = PIX_FMT_RGB32;
+ }
+
if ((of->oformat->flags & AVFMT_GLOBALHEADER)
// || !strcmp(of->oformat->name, "mp4")
// || !strcmp(of->oformat->name, "mov")
@@ -518,8 +525,8 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex
return NULL;
}
- video_buffersize = 2000000;
- video_buffer = (uint8_t*)MEM_mallocN(video_buffersize,
+ video_buffersize = avpicture_get_size(c->pix_fmt, c->width, c->height);
+ video_buffer = (uint8_t*)MEM_mallocN(video_buffersize*sizeof(uint8_t),
"FFMPEG video buffer");
current_frame = alloc_picture(c->pix_fmt, c->width, c->height);
@@ -565,6 +572,11 @@ static AVStream* alloc_audio_stream(RenderData *rd, int codec_id, AVFormatContex
return NULL;
}
+ /* need to prevent floating point exception when using vorbis audio codec,
+ initialize this value in the same way as it's done in FFmpeg iteslf (sergey) */
+ st->codec->time_base.num= 1;
+ st->codec->time_base.den= st->codec->sample_rate;
+
audio_outbuf_size = FF_MIN_BUFFER_SIZE;
if((c->codec_id >= CODEC_ID_PCM_S16LE) && (c->codec_id <= CODEC_ID_PCM_DVD))
@@ -737,7 +749,11 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report
}
}
- av_write_header(of);
+ if (av_write_header(of) < 0) {
+ BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination.");
+ return 0;
+ }
+
outfile = of;
av_dump_format(of, 0, name, 1);
@@ -808,7 +824,8 @@ void flush_ffmpeg(void)
********************************************************************** */
/* Get the output filename-- similar to the other output formats */
-void filepath_ffmpeg(char* string, RenderData* rd) {
+void filepath_ffmpeg(char* string, RenderData* rd)
+{
char autosplit[20];
const char ** exts = get_file_extensions(rd->ffcodecdata.type);
diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c
index d13d15d1269..d42b952617f 100644
--- a/source/blender/blenkernel/intern/writeframeserver.c
+++ b/source/blender/blenkernel/intern/writeframeserver.c
@@ -1,6 +1,3 @@
-/** \file blender/blenkernel/intern/writeframeserver.c
- * \ingroup bke
- */
/*
* $Id$
*
@@ -22,6 +19,10 @@
*
*/
+/** \file blender/blenkernel/intern/writeframeserver.c
+ * \ingroup bke
+ */
+
#ifdef WITH_FRAMESERVER
#include <string.h>
@@ -257,7 +258,11 @@ int frameserver_loop(RenderData *rd, ReportList *UNUSED(reports))
struct timeval tv;
struct sockaddr_in addr;
int len, rval;
+#ifdef FREE_WINDOWS
+ int socklen;
+#else
unsigned int socklen;
+#endif
char buf[4096];
if (connsock != -1) {