diff options
Diffstat (limited to 'source/blender/blenkernel')
32 files changed, 532 insertions, 128 deletions
diff --git a/source/blender/blenkernel/BKE_bad_level_calls.h b/source/blender/blenkernel/BKE_bad_level_calls.h index 0b623526562..93bfb2339be 100644 --- a/source/blender/blenkernel/BKE_bad_level_calls.h +++ b/source/blender/blenkernel/BKE_bad_level_calls.h @@ -230,5 +230,12 @@ void PE_free_particle_edit(struct ParticleSystem *psys); void PE_get_colors(char sel[4], char nosel[4]); void PE_recalc_world_cos(struct Object *ob, struct ParticleSystem *psys); +/* texture.c */ +struct Tex; +struct TexResult; +int multitex_thread(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres, short thread, short which_output); + + + #endif diff --git a/source/blender/blenkernel/BKE_fluidsim.h b/source/blender/blenkernel/BKE_fluidsim.h index 33c706da82b..4aac5eafa00 100644 --- a/source/blender/blenkernel/BKE_fluidsim.h +++ b/source/blender/blenkernel/BKE_fluidsim.h @@ -45,6 +45,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd); void fluidsim_free(FluidsimModifierData *fluidmd); DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifierData *fluidmd, int framenr, int useRenderParams); +void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename); DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc); // get bounding box of mesh diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 5620674e791..dc7c9dcd5e5 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -35,6 +35,7 @@ struct Lattice; struct Object; struct DerivedMesh; struct BPoint; +struct MDeformVert; extern struct Lattice *editLatt; @@ -67,5 +68,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]; void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]); void lattice_calc_modifiers(struct Object *ob); +struct MDeformVert* lattice_get_deform_verts(struct Object *lattice); + #endif diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 01c54663c6d..fa3a654c1c2 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -47,6 +47,7 @@ struct rctf; struct ListBase; struct RenderData; struct Scene; +struct Tex; struct GPUMaterial; struct GPUNode; struct GPUNodeStack; @@ -118,6 +119,8 @@ typedef struct bNodeType { #define NODE_CLASS_MATTE 9 #define NODE_CLASS_DISTORT 10 #define NODE_CLASS_OP_DYNAMIC 11 +#define NODE_CLASS_PATTERN 12 +#define NODE_CLASS_TEXTURE 13 /* ************** GENERIC API, TREES *************** */ @@ -377,6 +380,45 @@ void ntreeCompositForceHidden(struct bNodeTree *ntree); void free_compbuf(struct CompBuf *cbuf); /* internal...*/ + +/* ************** TEXTURE NODES *************** */ + +struct TexResult; + +#define TEX_NODE_OUTPUT 101 +#define TEX_NODE_CHECKER 102 +#define TEX_NODE_TEXTURE 103 +#define TEX_NODE_BRICKS 104 +#define TEX_NODE_MATH 105 +#define TEX_NODE_MIX_RGB 106 +#define TEX_NODE_RGBTOBW 107 +#define TEX_NODE_VALTORGB 108 +#define TEX_NODE_IMAGE 109 +#define TEX_NODE_CURVE_RGB 110 +#define TEX_NODE_INVERT 111 +#define TEX_NODE_HUE_SAT 112 +#define TEX_NODE_CURVE_TIME 113 +#define TEX_NODE_ROTATE 114 +#define TEX_NODE_VIEWER 115 +#define TEX_NODE_TRANSLATE 116 + +/* 201-299 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */ +#define TEX_NODE_PROC 200 +#define TEX_NODE_PROC_MAX 300 + +extern struct ListBase node_all_textures; + +/* API */ +int ntreeTexTagAnimated(struct bNodeTree *ntree); +void ntreeTexUpdatePreviews( struct bNodeTree* nodetree ); +void ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, char do_preview, short thread, struct Tex *tex, short which_output); +void ntreeTexCheckCyclics(struct bNodeTree *ntree); +void ntreeTexAssignIndex(struct bNodeTree *ntree, struct bNode *node); +char* ntreeTexOutputMenu(struct bNodeTree *ntree); + + +/**/ + void init_nodesystem(void); void free_nodesystem(void); diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index e8276238ff2..eed22ff9d8e 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -96,6 +96,7 @@ void space_transform_invert_normal(const SpaceTransform *data, float *no); struct Object; struct DerivedMesh; struct ShrinkwrapModifierData; +struct MDeformVert; struct BVHTree; @@ -109,6 +110,9 @@ typedef struct ShrinkwrapCalcData float (*vertexCos)[3]; //vertexs being shrinkwraped int numVerts; + struct MDeformVert* dvert; //Pointer to mdeform array + int vgroup; //Vertex group num + struct DerivedMesh *target; //mesh we are shrinking to SpaceTransform local2target; //transform to move bettwem local and target space diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 9662d6fbff8..6584af085cd 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -102,7 +102,7 @@ #define AVG2(x, y) ( 0.5 * ((x) + (y)) ) -#define FTOCHAR(val) (val<=0.0f)? 0 : ((val>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*val)+0.5f)) +#define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f)) #define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);} #define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);} diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c3cbc36a94f..0ed4f38e457 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -47,6 +47,10 @@ IF(WITH_OPENEXR) ADD_DEFINITIONS(-DWITH_OPENEXR) ENDIF(WITH_OPENEXR) +IF(WITH_DDS) + ADD_DEFINITIONS(-DWITH_DDS) +ENDIF(WITH_DDS) + IF(WITH_QUICKTIME) SET(INC ${INC} ${QUICKTIME_INC}) ADD_DEFINITIONS(-DWITH_QUICKTIME) diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 82743ef5ea7..ab122e40bfc 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -4,23 +4,33 @@ Import ('env') sources = env.Glob('intern/*.c') incs = '. #/intern/guardedalloc ../include ../blenlib ../makesdna' -incs += ' ../python ../render/extern/include #/intern/decimation/extern' +incs += ' ../render/extern/include #/intern/decimation/extern' incs += ' ../imbuf ../avi #/intern/elbeem/extern ../nodes' -incs += ' #/intern/iksolver/extern ../blenloader ../quicktime' +incs += ' #/intern/iksolver/extern ../blenloader' incs += ' #/extern/bullet2/src' incs += ' #/intern/bmfont' incs += ' #/intern/opennl/extern' incs += ' ../gpu #/extern/glew/include' -incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] -incs += ' ' + env['BF_SDL_INC'] defs = '' +if not env['WITH_BF_PYTHON']: + defs += 'DISABLE_PYTHON' +else: + incs += ' ../python' + incs += ' ' + env['BF_PYTHON_INC'] + +if env['WITH_BF_QUICKTIME']: + incs += ' ../quicktime' + +if env['WITH_BF_SDL']: + incs += ' ' + env['BF_SDL_INC'] + if env['WITH_BF_INTERNATIONAL']: - defs += 'WITH_FREETYPE2' + defs += ' WITH_FREETYPE2' if env['WITH_BF_VERSE']: defs += ' WITH_VERSE' diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index ae336d0fc26..91fb9031597 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -347,3 +347,6 @@ void txt_copy_clipboard (struct Text *text){} char stipple_quarttone[1]; +/* texture.c */ +int multitex_thread(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres, short thread, short which_output) {return 0;} + diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index ce4458b4307..cee032f364e 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1245,9 +1245,11 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { } } - avgSharpness /= sharpCount; - if (avgSharpness>1.0) { - avgSharpness = 1.0; + if(sharpCount) { + avgSharpness /= sharpCount; + if (avgSharpness>1.0) { + avgSharpness = 1.0; + } } if (seam && seamEdges < 2) @@ -1543,9 +1545,11 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { } } - avgSharpness /= sharpCount; - if (avgSharpness>1.0) { - avgSharpness = 1.0; + if(sharpCount) { + avgSharpness /= sharpCount; + if (avgSharpness>1.0) { + avgSharpness = 1.0; + } } if (seam && seamEdges < 2) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 1fe6447752e..5dcccc56d06 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -30,11 +30,15 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef WIN32 - #include <unistd.h> // for read close - #include <sys/param.h> // for MAXPATHLEN +#ifndef _WIN32 + #include <unistd.h> // for read close + #include <sys/param.h> // for MAXPATHLEN #else - #include <io.h> // for open close read + #include <io.h> // for open close read + #define open _open + #define read _read + #define close _close + #define write _write #endif #include <stdlib.h> diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 4914732b801..5639f00ee39 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -64,8 +64,9 @@ #include "BKE_library.h" #include "BKE_idprop.h" - +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include "blendef.h" @@ -1814,6 +1815,7 @@ static bConstraintTypeInfo CTI_SIZELIKE = { sizelike_evaluate /* evaluate */ }; + /* ----------- Python Constraint -------------- */ static void pycon_free (bConstraint *con) @@ -1888,8 +1890,10 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* only execute target calculation if allowed */ +#ifndef DISABLE_PYTHON if (G.f & G_DOSCRIPTLINKS) BPY_pyconstraint_target(data, ct); +#endif } else if (ct) Mat4One(ct->matrix); @@ -1897,6 +1901,9 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) { +#ifdef DISABLE_PYTHON + return; +#else bPythonConstraint *data= con->data; /* only evaluate in python if we're allowed to do so */ @@ -1913,6 +1920,7 @@ static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targ /* Now, run the actual 'constraint' function, which should only access the matrices */ BPY_pyconstraint_eval(data, cob, targets); +#endif /* DISABLE_PYTHON */ } static bConstraintTypeInfo CTI_PYTHON = { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index b090ac2b538..1a671dfe771 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1100,9 +1100,12 @@ float *make_orco_curve(Object *ob) fp[1]= 2.0f*v/(dl->nr-1) - 1.0f; fp[2]= 0.0; } else { + float *vert; int realv= v % dl->nr; - - VECCOPY(fp, &dl->verts[(dl->nr*u + realv)*3]); + int realu= u % dl->parts; + + vert= dl->verts + 3*(dl->nr*realu + realv); + VECCOPY(fp, vert); fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 3143c5e4df2..47736865273 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -239,12 +239,9 @@ float deformvert_get_weight(const struct MDeformVert *dvert, int group_num) float vertexgroup_get_vertex_weight(const struct MDeformVert *dvert, int index, int group_num) { - if(group_num == -1) + if(group_num == -1 || dvert == NULL) return 1.0; - if(dvert == 0) - return 0.0; - return deformvert_get_weight(dvert+index, group_num); } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 7f4910a9765..59619b25f8b 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -79,7 +79,9 @@ #include "MEM_guardedalloc.h" #include "blendef.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include "depsgraph_private.h" @@ -313,6 +315,7 @@ static void dag_add_driver_relation(Ipo *ipo, DagForest *dag, DagNode *node, int if ((icu->driver->flag & IPO_DRIVER_FLAG_INVALID) || (icu->driver->name[0] == '\0')) continue; /* empty or invalid expression */ +#ifndef DISABLE_PYTHON else { /* now we need refs to all objects mentioned in this * pydriver expression, to call 'dag_add_relation' @@ -334,6 +337,7 @@ static void dag_add_driver_relation(Ipo *ipo, DagForest *dag, DagNode *node, int MEM_freeN(obarray); } } +#endif /* DISABLE_PYTHON */ } else if (icu->driver->ob) { node1 = dag_get_node(dag, icu->driver->ob); @@ -491,8 +495,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Object *ob, int else dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Curve Parent"); } - else - dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Curve Parent"); + else + dag_add_relation(dag,node2,node,DAG_RL_OB_OB, "Parent"); } /* exception case: parent is duplivert */ if(ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3b6820461be..35097c05358 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1381,7 +1381,7 @@ void makeDispListSurf(Object *ob, ListBase *dispbase, int forRender) for (nu=nubase->first; nu; nu=nu->next) { if(forRender || nu->hide==0) { if(nu->pntsv==1) { - len= nu->resolu*SEGMENTSU(nu)+1; + len= nu->pntsu*nu->resolu; dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 561b564ac39..ee3fd59fe9f 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -76,10 +76,14 @@ #include <fcntl.h> #include <string.h> -#ifndef WIN32 +#ifndef _WIN32 #include <unistd.h> #else #include <io.h> +#define open _open +#define read _read +#define close _close +#define write _write #endif #include "MEM_guardedalloc.h" @@ -117,7 +121,9 @@ #include "BKE_curve.h" #include "BKE_customdata.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include "blendef.h" @@ -2427,6 +2433,7 @@ int BKE_read_exotic(char *name) read_stl_mesh_binary(name); retval = 1; } +#ifndef DISABLE_PYTHON // TODO: this should not be in the kernel... else { // unknown format, call Python importloader if (BPY_call_importloader(name)) { @@ -2436,6 +2443,7 @@ int BKE_read_exotic(char *name) } } +#endif /* DISABLE_PYTHON */ waitcursor(0); } } diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 4580c6cbf8b..29c4e0f2fb5 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -139,6 +139,9 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); */ + // (ab)used to store velocities + fss->meshSurfNormals = NULL; + fss->lastgoodframe = -1; fss->flag = 0; @@ -153,6 +156,11 @@ void fluidsim_free(FluidsimModifierData *fluidmd) #ifndef DISABLE_ELBEEM if(fluidmd) { + if(fluidmd->fss->meshSurfNormals) + { + MEM_freeN(fluidmd->fss->meshSurfNormals); + fluidmd->fss->meshSurfNormals = NULL; + } MEM_freeN(fluidmd->fss); } #endif @@ -462,21 +470,86 @@ DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, FluidsimModifie // load vertex velocities, if they exist... // TODO? use generate flag as loading flag as well? // warning, needs original .bobj.gz mesh loading filename - /* if(displaymode==3) { - readVelgz(targetFile, srcob); + fluidsim_read_vel_cache(fluidmd, dm, targetFile); } else { - // no data for preview, only clear... - int i,j; - for(i=0; i<mesh->totvert;i++) { for(j=0; j<3; j++) { srcob->fluidsimSettings->meshSurfNormals[i].co[j] = 0.; }} - }*/ + if(fss->meshSurfNormals) + MEM_freeN(fss->meshSurfNormals); + + fss->meshSurfNormals = NULL; + } return dm; } + +/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */ +void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh *dm, char *filename) +{ + int wri, i, j; + float wrf; + gzFile gzf; + FluidsimSettings *fss = fluidmd->fss; + int len = strlen(filename); + int totvert = dm->getNumVerts(dm); + float *velarray = NULL; + + // mesh and vverts have to be valid from loading... + + if(fss->meshSurfNormals) + MEM_freeN(fss->meshSurfNormals); + + if(len<7) + { + return; + } + + if(fss->domainNovecgen>0) return; + + // abusing pointer to hold an array of 3d-velocities + fss->meshSurfNormals = MEM_callocN(sizeof(float)*3*dm->getNumVerts(dm), "Fluidsim_velocities"); + // abusing pointer to hold an INT + fss->meshSurface = SET_INT_IN_POINTER(totvert); + + velarray = (float *)fss->meshSurfNormals; + + // .bobj.gz , correct filename + // 87654321 + filename[len-6] = 'v'; + filename[len-5] = 'e'; + filename[len-4] = 'l'; + + gzf = gzopen(filename, "rb"); + if (!gzf) + { + MEM_freeN(fss->meshSurfNormals); + fss->meshSurfNormals = NULL; + return; + } + + gzread(gzf, &wri, sizeof( wri )); + if(wri != totvert) + { + MEM_freeN(fss->meshSurfNormals); + fss->meshSurfNormals = NULL; + return; + } + + for(i=0; i<totvert;i++) + { + for(j=0; j<3; j++) + { + gzread(gzf, &wrf, sizeof( wrf )); + velarray[3*i + j] = wrf; + } + } + + gzclose(gzf); +} + void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], /*RET*/ float start[3], /*RET*/ float size[3] ) { @@ -583,60 +656,5 @@ void initElbeemMesh(struct Object *ob, dm->release(dm); } -/* read zipped fluidsim velocities into the co's of the fluidsimsettings normals struct */ -void readVelgz(char *filename, Object *srcob) -{ - int wri, i, j; - float wrf; - gzFile gzf; - MVert *vverts = srcob->fluidsimSettings->meshSurfNormals; - int len = strlen(filename); - Mesh *mesh = srcob->data; - // mesh and vverts have to be valid from loading... - - // clean up in any case - for(i=0; i<mesh->totvert;i++) - { - for(j=0; j<3; j++) - { - vverts[i].co[j] = 0.; - } - } - if(srcob->fluidsimSettings->domainNovecgen>0) return; - - if(len<7) - { - return; - } - - // .bobj.gz , correct filename - // 87654321 - filename[len-6] = 'v'; - filename[len-5] = 'e'; - filename[len-4] = 'l'; - - gzf = gzopen(filename, "rb"); - if (!gzf) - return; - - gzread(gzf, &wri, sizeof( wri )); - if(wri != mesh->totvert) - { - return; - } - - for(i=0; i<mesh->totvert;i++) - { - for(j=0; j<3; j++) - { - gzread(gzf, &wrf, sizeof( wrf )); - vverts[i].co[j] = wrf; - } - } - - gzclose(gzf); -} - - #endif // DISABLE_ELBEEM diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 9f0ea0f1388..29db0ddd808 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -73,7 +73,10 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_object.h" + +#ifndef DISABLE_PYTHON #include "BPY_extern.h" /* for BPY_pydriver_eval() */ +#endif #define SMALL -1.0e-10 @@ -1008,6 +1011,7 @@ static void posechannel_get_local_transform (bPoseChannel *pchan, float loc[], f */ static float eval_driver (IpoDriver *driver, float ipotime) { +#ifndef DISABLE_PYTHON /* currently, drivers are either PyDrivers (evaluating a PyExpression, or Object/Pose-Channel transforms) */ if (driver->type == IPO_DRIVER_TYPE_PYTHON) { /* check for empty or invalid expression */ @@ -1022,7 +1026,10 @@ static float eval_driver (IpoDriver *driver, float ipotime) */ return BPY_pydriver_eval(driver); } - else { + else +#endif /* DISABLE_PYTHON */ + { + Object *ob= driver->ob; /* must have an object to evaluate */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 54915058bab..6614c657647 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -928,3 +928,15 @@ void lattice_calc_modifiers(Object *ob) BLI_addtail(&ob->disp, dl); } } + +struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt) +{ + if(oblatt->type == OB_LATTICE) + { + Lattice *lt = (oblatt==G.obedit)?editLatt:(Lattice*)oblatt->data; + return lt->dvert; + } + + return NULL; +} + diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3d1b342bf73..33c1a4da4c7 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -597,6 +597,8 @@ static void get_flags_for_id(ID *id, char *buf) if(GS(id->name)==ID_MA) isnode= ((Material *)id)->use_nodes; + if(GS(id->name)==ID_TE) + isnode= ((Tex *)id)->use_nodes; if (id->us<0) sprintf(buf, "-1W "); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index b47e4d2ebaa..a5832711a81 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -59,7 +59,9 @@ #include "BKE_node.h" #include "BKE_utildefines.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include "GPU_material.h" @@ -78,7 +80,9 @@ void free_material(Material *ma) MTex *mtex; int a; +#ifndef DISABLE_PYTHON BPY_free_scriptlink(&ma->scriptlink); +#endif for(a=0; a<MAX_MTEX; a++) { mtex= ma->mtex[a]; @@ -209,8 +213,10 @@ Material *copy_material(Material *ma) id_us_plus((ID *)man->mtex[a]->tex); } } - + +#ifndef DISABLE_PYTHON BPY_copy_scriptlink(&ma->scriptlink); +#endif if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); @@ -652,7 +658,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) if(ma->septex & (1<<a)) continue; mtex= ma->mtex[a]; - if(mtex && mtex->tex && mtex->tex->type) { + if(mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) { ma->texco |= mtex->texco; ma->mapto |= mtex->mapto; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 13dc2e834f2..6bdd395a2ac 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -7804,9 +7804,10 @@ static void shrinkwrapModifier_deformVerts(ModifierData *md, Object *ob, Derived { if(derivedData) dm = CDDM_copy(derivedData); else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob); + else if(ob->type==OB_LATTICE) dm = NULL; else return; - if(dataMask & CD_MVERT) + if(dm != NULL && (dataMask & CD_MVERT)) { CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); @@ -7828,9 +7829,10 @@ static void shrinkwrapModifier_deformVertsEM(ModifierData *md, Object *ob, EditM { if(derivedData) dm = CDDM_copy(derivedData); else if(ob->type==OB_MESH) dm = CDDM_from_editmesh(editData, ob->data); + else if(ob->type==OB_LATTICE) dm = NULL; else return; - if(dataMask & CD_MVERT) + if(dm != NULL && (dataMask & CD_MVERT)) { CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); @@ -7916,9 +7918,10 @@ static void simpledeformModifier_deformVerts(ModifierData *md, Object *ob, Deriv { if(derivedData) dm = CDDM_copy(derivedData); else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob); + else if(ob->type==OB_LATTICE) dm = NULL; else return; - if(dataMask & CD_MVERT) + if(dm != NULL && (dataMask & CD_MVERT)) { CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); @@ -7942,9 +7945,10 @@ static void simpledeformModifier_deformVertsEM(ModifierData *md, Object *ob, Edi { if(derivedData) dm = CDDM_copy(derivedData); else if(ob->type==OB_MESH) dm = CDDM_from_editmesh(editData, ob->data); + else if(ob->type==OB_LATTICE) dm = NULL; else return; - if(dataMask & CD_MVERT) + if(dm != NULL && (dataMask & CD_MVERT)) { CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 94a21cdd5df..ae81a31c373 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -27,7 +27,10 @@ * ***** END GPL LICENSE BLOCK ***** */ +#ifndef DISABLE_PYTHON #include <Python.h> +#endif + #include <stdlib.h> #include <string.h> @@ -35,6 +38,7 @@ #include "DNA_image_types.h" #include "DNA_node_types.h" #include "DNA_material_types.h" +#include "DNA_texture_types.h" #include "DNA_text_types.h" #include "DNA_scene_types.h" @@ -67,6 +71,8 @@ #include "intern/CMP_util.h" /* stupid include path... */ #include "SHD_node.h" +#include "TEX_node.h" +#include "intern/TEX_util.h" #include "GPU_extensions.h" #include "GPU_material.h" @@ -74,6 +80,7 @@ static ListBase empty_list = {NULL, NULL}; ListBase node_all_composit = {NULL, NULL}; ListBase node_all_shaders = {NULL, NULL}; +ListBase node_all_textures = {NULL, NULL}; /* ************** Type stuff ********** */ @@ -103,6 +110,8 @@ void ntreeInitTypes(bNodeTree *ntree) ntree->alltypes= node_all_shaders; else if(ntree->type==NTREE_COMPOSIT) ntree->alltypes= node_all_composit; + else if(ntree->type==NTREE_TEXTURE) + ntree->alltypes= node_all_textures; else { ntree->alltypes= empty_list; printf("Error: no type definitions for nodes\n"); @@ -658,6 +667,28 @@ void nodeVerifyGroup(bNodeTree *ngroup) } } } + else if(ngroup->type==NTREE_TEXTURE) { + Tex *tx; + for(tx= G.main->tex.first; tx; tx= tx->id.next) { + if(tx->nodetree) { + bNode *node; + + /* find if group is in tree */ + for(node= tx->nodetree->nodes.first; node; node= node->next) + if(node->id == (ID *)ngroup) + break; + + if(node) { + /* set all type pointers OK */ + ntreeInitTypes(tx->nodetree); + + for(node= tx->nodetree->nodes.first; node; node= node->next) + if(node->id == (ID *)ngroup) + nodeVerifyType(tx->nodetree, node); + } + } + } + } } /* also to check all users of groups. Now only used in editor for hide/unhide */ @@ -714,6 +745,26 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup) } } } + else if(ngroup->type==NTREE_TEXTURE) { + Tex *tx; + for(tx= G.main->tex.first; tx; tx= tx->id.next) { + if(tx->nodetree) { + for(node= tx->nodetree->nodes.first; node; node= node->next) { + if(node->id==(ID *)ngroup) { + for(sock= node->inputs.first; sock; sock= sock->next) + if(sock->link) + if(sock->tosock) + sock->tosock->flag |= SOCK_IN_USE; + for(sock= node->outputs.first; sock; sock= sock->next) + if(nodeCountSocketLinks(tx->nodetree, sock)) + if(sock->tosock) + sock->tosock->flag |= SOCK_IN_USE; + } + } + } + } + } + } /* finds a node based on given socket */ @@ -898,9 +949,12 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) /* got it-bob*/ if(ntype->initfunc!=NULL) ntype->initfunc(node); + + if(type==TEX_NODE_OUTPUT) + ntreeTexAssignIndex(ntree, node); nodeAddSockets(node, ntype); - + return node; } @@ -967,6 +1021,9 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) node->new_node= nnode; nnode->new_node= NULL; nnode->preview= NULL; + + if(node->type==TEX_NODE_OUTPUT) + ntreeTexAssignIndex(ntree, node); return nnode; } @@ -1257,6 +1314,22 @@ void ntreeMakeLocal(bNodeTree *ntree) } } } + else if(ntree->type==NTREE_TEXTURE) { + Tex *tx; + for(tx= G.main->tex.first; tx; tx= tx->id.next) { + if(tx->nodetree) { + bNode *node; + + /* find if group is in tree */ + for(node= tx->nodetree->nodes.first; node; node= node->next) { + if(node->id == (ID *)ntree) { + if(tx->id.lib) lib= 1; + else local= 1; + } + } + } + } + } /* if all users are local, we simply make tree local */ if(local && lib==0) { @@ -1308,6 +1381,25 @@ void ntreeMakeLocal(bNodeTree *ntree) } } } + else if(ntree->type==NTREE_TEXTURE) { + Tex *tx; + for(tx= G.main->tex.first; tx; tx= tx->id.next) { + if(tx->nodetree) { + bNode *node; + + /* find if group is in tree */ + for(node= tx->nodetree->nodes.first; node; node= node->next) { + if(node->id == (ID *)ntree) { + if(tx->id.lib==NULL) { + node->id= &newtree->id; + newtree->id.us++; + ntree->id.us--; + } + } + } + } + } + } } } @@ -1572,6 +1664,8 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node) } node->need_exec= 1; } + else if(ntree->type == NTREE_TEXTURE) + ntreeTexUpdatePreviews(ntree); } void NodeTagIDChanged(bNodeTree *ntree, ID *id) @@ -1810,7 +1904,7 @@ static void composit_begin_exec(bNodeTree *ntree, int is_group) sock->ns.data= NULL; } } - } + } /* cannot initialize them while using in threads */ if(ELEM3(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB)) { curvemapping_initialize(node->storage); @@ -1926,12 +2020,28 @@ static void ntreeReleaseThreadStack(bNodeThreadStack *nts) nts->used= 0; } +/* free texture delegates */ +static void tex_end_exec(bNodeTree *ntree) +{ + bNodeThreadStack *nts; + bNodeStack *ns; + int th, a; + + if(ntree->threadstack) + for(th=0; th<BLENDER_MAX_THREADS; th++) + for(nts=ntree->threadstack[th].first; nts; nts=nts->next) + for(ns= nts->stack, a=0; a<ntree->stacksize; a++, ns++) + if(ns->data) + MEM_freeN(ns->data); + +} + void ntreeBeginExecTree(bNodeTree *ntree) { /* let's make it sure */ if(ntree->init & NTREE_EXEC_INIT) return; - + /* allocate the thread stack listbase array */ if(ntree->type!=NTREE_COMPOSIT) ntree->threadstack= MEM_callocN(BLENDER_MAX_THREADS*sizeof(ListBase), "thread stack array"); @@ -1983,6 +2093,8 @@ void ntreeEndExecTree(bNodeTree *ntree) /* another callback candidate! */ if(ntree->type==NTREE_COMPOSIT) composit_end_exec(ntree, 0); + else if(ntree->type==NTREE_TEXTURE) + tex_end_exec(ntree); if(ntree->stack) { MEM_freeN(ntree->stack); @@ -2619,6 +2731,27 @@ void ntreeCompositTagGenerators(bNodeTree *ntree) } } +int ntreeTexTagAnimated(bNodeTree *ntree) +{ + bNode *node; + + if(ntree==NULL) return 0; + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type==TEX_NODE_CURVE_TIME) { + NodeTagChanged(ntree, node); + return 1; + } + else if(node->type==NODE_GROUP) { + if( ntreeTexTagAnimated((bNodeTree *)node->id) ) { + return 1; + } + } + } + + return 0; +} + /* ************* node definition init ********** */ static bNodeType *is_nodetype_registered(ListBase *typelist, int type, ID *id) @@ -2742,6 +2875,41 @@ static void registerShaderNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &sh_node_hue_sat); } +static void registerTextureNodes(ListBase *ntypelist) +{ + nodeRegisterType(ntypelist, &node_group_typeinfo); + nodeRegisterType(ntypelist, &tex_node_math); + nodeRegisterType(ntypelist, &tex_node_mix_rgb); + nodeRegisterType(ntypelist, &tex_node_valtorgb); + nodeRegisterType(ntypelist, &tex_node_rgbtobw); + nodeRegisterType(ntypelist, &tex_node_curve_rgb); + nodeRegisterType(ntypelist, &tex_node_curve_time); + nodeRegisterType(ntypelist, &tex_node_invert); + nodeRegisterType(ntypelist, &tex_node_hue_sat); + + nodeRegisterType(ntypelist, &tex_node_output); + nodeRegisterType(ntypelist, &tex_node_viewer); + + nodeRegisterType(ntypelist, &tex_node_checker); + nodeRegisterType(ntypelist, &tex_node_texture); + nodeRegisterType(ntypelist, &tex_node_bricks); + nodeRegisterType(ntypelist, &tex_node_image); + + nodeRegisterType(ntypelist, &tex_node_rotate); + nodeRegisterType(ntypelist, &tex_node_translate); + + nodeRegisterType(ntypelist, &tex_node_proc_voronoi); + nodeRegisterType(ntypelist, &tex_node_proc_blend); + nodeRegisterType(ntypelist, &tex_node_proc_magic); + nodeRegisterType(ntypelist, &tex_node_proc_marble); + nodeRegisterType(ntypelist, &tex_node_proc_clouds); + nodeRegisterType(ntypelist, &tex_node_proc_wood); + nodeRegisterType(ntypelist, &tex_node_proc_musgrave); + nodeRegisterType(ntypelist, &tex_node_proc_noise); + nodeRegisterType(ntypelist, &tex_node_proc_stucci); + nodeRegisterType(ntypelist, &tex_node_proc_distnoise); +} + static void remove_dynamic_typeinfos(ListBase *list) { bNodeType *ntype= list->first; @@ -2779,6 +2947,7 @@ void init_nodesystem(void) { registerCompositNodes(&node_all_composit); registerShaderNodes(&node_all_shaders); + registerTextureNodes(&node_all_textures); } void free_nodesystem(void) @@ -2787,4 +2956,5 @@ void free_nodesystem(void) BLI_freelistN(&node_all_composit); remove_dynamic_typeinfos(&node_all_shaders); BLI_freelistN(&node_all_shaders); + BLI_freelistN(&node_all_textures); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b6f6820ca73..a25afeafaef 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -111,7 +111,9 @@ #include "LBM_fluidsim.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #include "GPU_material.h" @@ -269,8 +271,10 @@ void free_object(Object *ob) free_constraints(&ob->constraints); free_constraint_channels(&ob->constraintChannels); free_nlastrips(&ob->nlastrips); - + +#ifndef DISABLE_PYTHON BPY_free_scriptlink(&ob->scriptlink); +#endif if(ob->pd){ if(ob->pd->tex) @@ -637,9 +641,9 @@ Camera *copy_camera(Camera *cam) camn= copy_libblock(cam); id_us_plus((ID *)camn->ipo); - +#ifndef DISABLE_PYTHON BPY_copy_scriptlink(&camn->scriptlink); - +#endif return camn; } @@ -786,9 +790,9 @@ Lamp *copy_lamp(Lamp *la) id_us_plus((ID *)lan->ipo); if (la->preview) lan->preview = BKE_previewimg_copy(la->preview); - +#ifndef DISABLE_PYTHON BPY_copy_scriptlink(&la->scriptlink); - +#endif return lan; } @@ -846,7 +850,9 @@ void make_local_lamp(Lamp *la) void free_camera(Camera *ca) { +#ifndef DISABLE_PYTHON BPY_free_scriptlink(&ca->scriptlink); +#endif } void free_lamp(Lamp *la) @@ -855,8 +861,9 @@ void free_lamp(Lamp *la) int a; /* scriptlinks */ - +#ifndef DISABLE_PYTHON BPY_free_scriptlink(&la->scriptlink); +#endif for(a=0; a<MAX_MTEX; a++) { mtex= la->mtex[a]; @@ -1156,7 +1163,10 @@ static void copy_object_pose(Object *obn, Object *ob) ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - if(con->ipo) { + /* note that we can't change lib linked ipo blocks. for making + * proxies this still works correct however because the object + * is changed to object->proxy_from when evaluating the driver. */ + if(con->ipo && !con->ipo->id.lib) { IpoCurve *icu; for(icu= con->ipo->curve.first; icu; icu= icu->next) { if(icu->driver && icu->driver->ob==ob) @@ -1202,9 +1212,9 @@ Object *copy_object(Object *ob) modifier_copyData(md, nmd); BLI_addtail(&obn->modifiers, nmd); } - +#ifndef DISABLE_PYTHON BPY_copy_scriptlink(&ob->scriptlink); - +#endif obn->prop.first = obn->prop.last = NULL; copy_properties(&obn->prop, &ob->prop); @@ -1918,10 +1928,11 @@ void where_is_object_time(Object *ob, float ctime) constraints_clear_evalob(cob); } - +#ifndef DISABLE_PYTHON if(ob->scriptlink.totscript && !during_script()) { if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_REDRAW); } +#endif /* set negative scale flag in object */ Crossf(vec, ob->obmat[0], ob->obmat[1]); @@ -2288,7 +2299,9 @@ void object_handle_update(Object *ob) } else where_is_object(ob); +#ifndef DISABLE_PYTHON if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBJECTUPDATE); +#endif } if(ob->recalc & OB_RECALC_DATA) { @@ -2364,7 +2377,9 @@ void object_handle_update(Object *ob) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } +#ifndef DISABLE_PYTHON if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBDATAUPDATE); +#endif } /* the no-group proxy case, we call update */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index dea36a69643..1727edc10fc 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -82,7 +82,10 @@ #include "BIF_previewrender.h" #include "BIF_editseq.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif + #include "BLI_arithb.h" #include "BLI_blenlib.h" @@ -139,7 +142,10 @@ void free_scene(Scene *sce) if(sce->radio) MEM_freeN(sce->radio); sce->radio= 0; +#ifndef DISABLE_PYTHON BPY_free_scriptlink(&sce->scriptlink); +#endif + if (sce->r.avicodecdata) { free_avicodecdata(sce->r.avicodecdata); MEM_freeN(sce->r.avicodecdata); @@ -253,6 +259,21 @@ Scene *add_scene(char *name) sce->toolsettings->select_thresh= 0.01f; sce->toolsettings->jointrilimit = 0.8f; + 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_length_ratio = 1.3f; + sce->toolsettings->skgen_length_limit = 1.5f; + sce->toolsettings->skgen_correlation_limit = 0.98f; + sce->toolsettings->skgen_symmetry_limit = 0.1f; + sce->toolsettings->skgen_postpro = SKGEN_SMOOTH; + sce->toolsettings->skgen_postpro_passes = 1; + sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_HARMONIC|SKGEN_SUB_CORRELATION|SKGEN_STICK_TO_EMBEDDING; + sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; + sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; + sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; + pset= &sce->toolsettings->particle; pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; pset->emitterdist= 0.25f; @@ -570,9 +591,9 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) /* object ipos are calculated in where_is_object */ do_all_data_ipos(); - +#ifndef DISABLE_PYTHON if (G.f & G_DOSCRIPTLINKS) BPY_do_all_scripts(SCRIPT_FRAMECHANGED, 0); - +#endif /* sets first, we allow per definition current scene to have dependencies on sets */ for(sce= sce->set; sce; sce= sce->set) scene_update(sce, lay); diff --git a/source/blender/blenkernel/intern/script.c b/source/blender/blenkernel/intern/script.c index b93821da218..6145f6c3063 100644 --- a/source/blender/blenkernel/intern/script.c +++ b/source/blender/blenkernel/intern/script.c @@ -44,7 +44,9 @@ #include "BKE_global.h" #include "BKE_main.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" // Blender Python library +#endif #ifdef HAVE_CONFIG_H #include <config.h> @@ -57,5 +59,7 @@ void free_script (Script *script) { if (!script) return; +#ifndef DISABLE_PYTHON BPY_clear_script(script); +#endif } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 28bf7aee884..ab98fb1f007 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -41,6 +41,7 @@ #include "BKE_shrinkwrap.h" #include "BKE_DerivedMesh.h" +#include "BKE_lattice.h" #include "BKE_utildefines.h" #include "BKE_deform.h" #include "BKE_cdderivedmesh.h" @@ -161,6 +162,18 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM calc.numVerts = numVerts; calc.vertexCos = vertexCos; + //DeformVertex + calc.vgroup = get_named_vertexgroup_num(calc.ob, calc.smd->vgroup_name); + if(calc.original) + { + calc.dvert = calc.original->getVertDataArray(calc.original, CD_MDEFORMVERT); + } + else if(calc.ob->type == OB_LATTICE) + { + calc.dvert = lattice_get_deform_verts(calc.ob); + } + + if(smd->target) { //TODO currently we need a copy in case object_get_derived_final returns an emDM that does not defines getVertArray or getFace array @@ -207,8 +220,6 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) { int i; - const int vgroup = get_named_vertexgroup_num(calc->ob, calc->smd->vgroup_name); - MDeformVert *const dvert = calc->original ? calc->original->getVertDataArray(calc->original, CD_MDEFORMVERT) : NULL; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; BVHTreeNearest nearest = NULL_BVHTreeNearest; @@ -230,7 +241,7 @@ void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) { float *co = calc->vertexCos[i]; float tmp_co[3]; - float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup); + float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; VECCOPY(tmp_co, co); @@ -342,11 +353,6 @@ void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) MVert *vert = NULL; //Needed in case of vertex normal DerivedMesh* ss_mesh = NULL; - //Vertex group data - const int vgroup = get_named_vertexgroup_num(calc->ob, calc->smd->vgroup_name); - const MDeformVert *dvert = calc->original ? calc->original->getVertDataArray(calc->original, CD_MDEFORMVERT) : NULL; - - //Raycast and tree stuff BVHTreeRayHit hit; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; //target @@ -441,7 +447,7 @@ do float *co = calc->vertexCos[i]; float tmp_co[3], tmp_no[3]; float lim = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isnt prepared for that - float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup); + float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; @@ -520,9 +526,6 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) { int i; - const int vgroup = get_named_vertexgroup_num(calc->ob, calc->smd->vgroup_name); - const MDeformVert *const dvert = calc->original ? calc->original->getVertDataArray(calc->original, CD_MDEFORMVERT) : NULL; - BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; BVHTreeNearest nearest = NULL_BVHTreeNearest; @@ -547,7 +550,7 @@ void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) { float *co = calc->vertexCos[i]; float tmp_co[3]; - float weight = vertexgroup_get_vertex_weight(dvert, i, vgroup); + float weight = vertexgroup_get_vertex_weight(calc->dvert, i, calc->vgroup); if(weight == 0.0f) continue; //Convert the vertex to tree coordinates diff --git a/source/blender/blenkernel/intern/simple_deform.c b/source/blender/blenkernel/intern/simple_deform.c index 0eb710fa48e..2978a6f7f01 100644 --- a/source/blender/blenkernel/intern/simple_deform.c +++ b/source/blender/blenkernel/intern/simple_deform.c @@ -32,6 +32,7 @@ #include "BKE_simple_deform.h" #include "BKE_DerivedMesh.h" +#include "BKE_lattice.h" #include "BKE_deform.h" #include "BKE_utildefines.h" #include "BLI_arithb.h" @@ -204,7 +205,14 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, s if(dm) - dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); + { + dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); + } + else if(ob->type == OB_LATTICE) + { + dvert = lattice_get_deform_verts(ob); + } + switch(smd->mode) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 9e6efa59d71..d33721541f8 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -47,7 +47,9 @@ #include "BKE_global.h" #include "BKE_main.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #ifdef HAVE_CONFIG_H #include <config.h> @@ -158,7 +160,9 @@ void free_text(Text *text) if(text->name) MEM_freeN(text->name); MEM_freeN(text->undo_buf); +#ifndef DISABLE_PYTHON if (text->compiled) BPY_free_compiled_text(text); +#endif } Text *add_empty_text(char *name) @@ -571,7 +575,9 @@ int txt_get_span (TextLine *from, TextLine *to) static void txt_make_dirty (Text *text) { text->flags |= TXT_ISDIRTY; +#ifndef DISABLE_PYTHON if (text->compiled) BPY_free_compiled_text(text); +#endif } /* 0:whitespace, 1:punct, 2:alphanumeric */ diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 1bb4ef3eeff..c972d70d927 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -349,6 +349,15 @@ int do_colorband(ColorBand *coba, float in, float out[4]) else fac= 0.0f; + if (coba->ipotype==4) { + /* constant */ + out[0]= cbd2->r; + out[1]= cbd2->g; + out[2]= cbd2->b; + out[3]= cbd2->a; + return 1; + } + if(coba->ipotype>=2) { /* ipo from right to left: 3 2 1 0 */ @@ -414,6 +423,11 @@ void free_texture(Tex *tex) BKE_previewimg_free(&tex->preview); BKE_icon_delete((struct ID*)tex); tex->id.icon_id = 0; + + if(tex->nodetree) { + ntreeFreeTree(tex->nodetree); + MEM_freeN(tex->nodetree); + } } /* ------------------------------------------------------------------------- */ @@ -577,6 +591,11 @@ Tex *copy_texture(Tex *tex) if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); + if(tex->nodetree) { + ntreeEndExecTree(tex->nodetree); + texn->nodetree= ntreeCopyTree(tex->nodetree, 0); /* 0 == full new tree */ + } + return texn; } @@ -727,6 +746,10 @@ void autotexname(Tex *tex) char di[FILE_MAXDIR], fi[FILE_MAXFILE]; if(tex) { + if(tex->use_nodes) { + new_id(&G.main->tex, (ID *)tex, "Noddy"); + } + else if(tex->type==TEX_IMAGE) { ima= tex->ima; if(ima) { diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 814d6f8baf1..2e89ce3f805 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -54,7 +54,9 @@ #include "BKE_main.h" #include "BKE_icons.h" +#ifndef DISABLE_PYTHON #include "BPY_extern.h" +#endif #ifdef HAVE_CONFIG_H #include <config.h> @@ -64,9 +66,10 @@ void free_world(World *wrld) { MTex *mtex; int a; - + +#ifndef DISABLE_PYTHON BPY_free_scriptlink(&wrld->scriptlink); - +#endif for(a=0; a<MAX_MTEX; a++) { mtex= wrld->mtex[a]; if(mtex && mtex->tex) mtex->tex->id.us--; @@ -124,9 +127,9 @@ World *copy_world(World *wrld) } if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview); - +#ifndef DISABLE_PYTHON BPY_copy_scriptlink(&wrld->scriptlink); - +#endif id_us_plus((ID *)wrldn->ipo); return wrldn; |