diff options
author | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-06-24 07:30:50 +0400 |
---|---|---|
committer | Xiao Xiangquan <xiaoxiangquan@gmail.com> | 2011-06-24 07:30:50 +0400 |
commit | b429af10d04d727574eb50a7186e8075ae8fb0b8 (patch) | |
tree | dae073488e49cb2a4107d3fe2d553711496bf4f9 /source/blender/blenkernel | |
parent | 9a2f36b50f818c0c1b659363a1df298f7043e207 (diff) |
merge from trunk #37722
Diffstat (limited to 'source/blender/blenkernel')
19 files changed, 138 insertions, 597 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 698f0f0fecf..7d3de68c005 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -216,7 +216,7 @@ void pose_remove_group(struct Object *ob); /* Assorted Evaluation ----------------- */ /* Used for the Action Constraint */ -void what_does_obaction(struct Scene *scene, struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); +void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); /* for proxy */ void copy_pose_result(struct bPose *to, struct bPose *from); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 07f0885372a..4ea5db93350 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -43,17 +43,17 @@ extern "C" { /* these lines are grep'd, watch out for our not-so-awesome regex * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ -#define BLENDER_VERSION 257 -#define BLENDER_SUBVERSION 1 +#define BLENDER_VERSION 258 +#define BLENDER_SUBVERSION 0 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR b +#define BLENDER_VERSION_CHAR /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE release struct ListBase; struct MemFile; diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 14251fb1762..f36073ba841 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -51,22 +51,23 @@ struct GHash; /* **** DAG relation types *** */ /* scene link to object */ -#define DAG_RL_SCENE 1 +#define DAG_RL_SCENE (1<<0) /* object link to data */ -#define DAG_RL_DATA 2 +#define DAG_RL_DATA (1<<1) /* object changes object (parent, track, constraints) */ -#define DAG_RL_OB_OB 4 +#define DAG_RL_OB_OB (1<<2) /* object changes obdata (hooks, constraints) */ -#define DAG_RL_OB_DATA 8 +#define DAG_RL_OB_DATA (1<<3) /* data changes object (vertex parent) */ -#define DAG_RL_DATA_OB 16 +#define DAG_RL_DATA_OB (1<<4) /* data changes data (deformers) */ -#define DAG_RL_DATA_DATA 32 +#define DAG_RL_DATA_DATA (1<<5) -#define DAG_NO_RELATION 64 -#define DAG_RL_ALL 63 -#define DAG_RL_ALL_BUT_DATA 61 +#define DAG_NO_RELATION (1<<6) + +#define DAG_RL_ALL_BUT_DATA (DAG_RL_SCENE|DAG_RL_OB_OB|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_DATA_DATA) +#define DAG_RL_ALL (DAG_RL_ALL_BUT_DATA|DAG_RL_DATA) typedef void (*graph_action_func)(void * ob, void **data); diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index 68745975dae..b00db53a199 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -97,15 +97,10 @@ extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); extern void makeDispListMBall(struct Scene *scene, struct Object *ob); extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -extern void shadeDispList(struct Scene *scene, struct Base *base); -extern void shadeMeshMCol(struct Scene *scene, struct Object *ob, struct Mesh *me); int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); -void reshadeall_displist(struct Scene *scene); void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); -void fastshade_free_render(void); - float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 4dfc53e1734..feeab98ad78 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -300,6 +300,8 @@ void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, in void psys_check_boid_data(struct ParticleSystem *psys); +void psys_get_birth_coordinates(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra); + void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys); /* ----------- functions needed only inside particlesystem ------------ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 5078657588d..9c06e325ce2 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -273,12 +273,12 @@ endif() if(WITH_CODEC_QUICKTIME) list(APPEND INC ../quicktime) - list(APPEND INC_SYS ${QUICKTIME_INC}) + list(APPEND INC_SYS ${QUICKTIME_INCLUDE_DIRS}) add_definitions(-DWITH_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) - list(APPEND INC_SYS ${FFMPEG_INC}) + list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS}) add_definitions(-DWITH_FFMPEG) endif() diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 1fed115893c..ef4f320602b 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -69,8 +69,9 @@ typedef struct DagNode void * ob; void * first_ancestor; int ancestor_count; - unsigned int lay; // accumulated layers of its relations + itself + unsigned int lay; // accumulated layers of its relations + itself unsigned int scelay; // layers due to being in scene + unsigned int customdata_mask; // customdata mask int lasttime; // if lasttime != DagForest->time, this node was not evaluated yet for flushing int BFS_dist; // BFS distance int DFS_dist; // DFS distance diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 77f56058a4f..f7086c81756 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1128,7 +1128,7 @@ void copy_pose_result(bPose *to, bPose *from) /* For the calculation of the effects of an Action at the given frame on an object * This is currently only used for the Action Constraint */ -void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) +void what_does_obaction (Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { bActionGroup *agrp= action_groups_find_named(act, groupname); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 1763866c000..0747d87a0ab 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -171,7 +171,12 @@ bMotionPath *animviz_verify_motionpaths(Scene *scene, Object *ob, bPoseChannel * avs= &ob->avs; dst= &ob->mpath; } - + + /* avoid 0 size allocs */ + if(avs->path_sf >= avs->path_ef) { + return NULL; + } + /* if there is already a motionpath, just return that, * but provided it's settings are ok */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index fd25ebe266f..0b31e51d62e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1343,8 +1343,12 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) cross_v3_v3v3(axis,target,nor); /* was 0.0000000000001, caused bug [#23954], smaller values give unstable - * roll when toggling editmode */ - if (dot_v3v3(axis,axis) > 0.00001f) { + * roll when toggling editmode. + * + * was 0.00001, causes bug [#27675], with 0.00000495, + * so a value inbetween these is needed. + */ + if (dot_v3v3(axis,axis) > 0.000001f) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5a9432552d2..0f545ad3ff9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -154,7 +154,6 @@ static void clear_global(void) { // extern short winqueue_break; /* screen.c */ - fastshade_free_render(); /* lamps hang otherwise */ free_main(G.main); /* free all lib data */ // free_vertexpaint(); diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 5520e4d1d41..cc45abb5998 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -493,7 +493,7 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float *co, // NOTE: casts to "float*" here are due to co being "const float*" closest_to_line_segment_v3(nearest_tmp, (float*)co, t0, t1); - dist = len_v3v3(nearest_tmp, (float*)co); + dist = len_squared_v3v3(nearest_tmp, (float*)co); if(dist < nearest->dist) { diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index d3c14a9dd12..7be4744a224 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -424,7 +424,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* ------------ General Target Matrix Tools ---------- */ /* function that sets the given matrix based on given vertex group in mesh */ -static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4]) +static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4]) { DerivedMesh *dm = NULL; Mesh *me= ob->data; @@ -449,16 +449,9 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substr freeDM= 1; } else { - /* when not in EditMode, use the 'final' derived mesh - * - check if the custom data masks for derivedFinal mean that we can just use that - * (this is more effficient + sufficient for most cases) - */ - if (!(ob->lastDataMask & CD_MASK_MDEFORMVERT)) { - dm = mesh_get_derived_final(scene, ob, CD_MASK_MDEFORMVERT); - freeDM= 1; - } - else - dm = (DerivedMesh *)ob->derivedFinal; + /* when not in EditMode, use the 'final' derived mesh, depsgraph + * ensures we build with CD_MDEFORMVERT layer */ + dm = (DerivedMesh *)ob->derivedFinal; } /* only continue if there's a valid DerivedMesh */ @@ -587,7 +580,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* generic function to get the appropriate matrix for most target cases */ /* The cases where the target can be object data have not been implemented */ -static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) +static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) { /* Case OBJECT */ if (!strlen(substring)) { @@ -604,7 +597,7 @@ static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *sub * way as constraints can only really affect things on object/bone level. */ else if (ob->type == OB_MESH) { - contarget_get_mesh_mat(scene, ob, substring, mat); + contarget_get_mesh_mat(ob, substring, mat); constraint_mat_convertspace(ob, NULL, mat, from, to); } else if (ob->type == OB_LATTICE) { @@ -684,10 +677,10 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { /* This function should be used for the get_target_matrix member of all * constraints that are not picky about what happens to their target matrix. */ -static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) unit_m4(ct->matrix); } @@ -1159,7 +1152,7 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra bKinematicConstraint *data= con->data; if (VALID_CONS_TARGET(ct)) - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) { if (data->flag & CONSTRAINT_IK_AUTO) { Object *ob= cob->ob; @@ -2046,7 +2039,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT /* firstly calculate the matrix the normal way, then let the py-function override * this matrix if it needs to do so */ - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* only execute target calculation if allowed */ #ifdef WITH_PYTHON @@ -2165,7 +2158,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint unit_m4(ct->matrix); /* get the transform matrix of the target */ - constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); + constraint_target_to_mat4(ct->tar, ct->subtarget, tempmat, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* determine where in transform range target is */ /* data->type is mapped as follows for backwards compatability: @@ -2216,7 +2209,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint tchan->rotmode= pchan->rotmode; /* evaluate action using workob (it will only set the PoseChannel in question) */ - what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t); + what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t); /* convert animation to matrices for use here */ pchan_calc_mat(tchan); @@ -2230,7 +2223,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* evaluate using workob */ // FIXME: we don't have any consistent standards on limiting effects on object... - what_does_obaction(cob->scene, cob->ob, &workob, NULL, data->act, NULL, t); + what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); object_to_mat4(&workob, ct->matrix); } else { diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 472d7d77b80..c2800410657 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -372,6 +372,9 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O node2->first_ancestor = ob; node2->ancestor_count += 1; } + + /* also build a custom data mask for dependencies that need certain layers */ + node->customdata_mask= 0; if (ob->type == OB_ARMATURE) { if (ob->pose){ @@ -451,8 +454,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O case PARSKEL: dag_add_relation(dag,node2,node,DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); break; - case PARVERT1: case PARVERT3: case PARBONE: + case PARVERT1: case PARVERT3: dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + node2->customdata_mask |= CD_MASK_ORIGINDEX; + break; + case PARBONE: + dag_add_relation(dag,node2,node,DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); break; default: if(ob->parent->type==OB_LATTICE) @@ -647,8 +654,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); else { - if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) + if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + if (obt->type == OB_MESH) + node2->customdata_mask |= CD_MASK_MDEFORMVERT; + } else dag_add_relation(dag, node2, node, DAG_RL_OB_OB, cti->name); } @@ -722,6 +732,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) itA->node->color |= itA->type; } } + + /* also flush custom data mask */ + ((Object*)node->ob)->customdata_mask= node->customdata_mask; } } /* now set relations equal, so that when only one parent changes, the correct recalcs are found */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9aa794aa97e..8f57490d057 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -65,9 +65,6 @@ #include "BKE_lattice.h" #include "BKE_modifier.h" -#include "RE_pipeline.h" -#include "RE_shader_ext.h" - #include "BLO_sys_types.h" // for intptr_t support #include "ED_curve.h" /* for BKE_curve_nurbs */ @@ -286,499 +283,6 @@ int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, i return 1; } -/* ***************************** shade displist. note colors now are in rgb(a) order ******************** */ - -/* create default shade input... save cpu cycles with ugly global */ -/* XXXX bad code warning: local ShadeInput initialize... */ -static ShadeInput shi; -static void init_fastshade_shadeinput(Render *re) -{ - memset(&shi, 0, sizeof(ShadeInput)); - shi.lay= RE_GetScene(re)->lay; - shi.view[2]= -1.0f; - shi.passflag= SCE_PASS_COMBINED; - shi.combinedflag= -1; -} - -static Render *fastshade_get_render(Scene *UNUSED(scene)) -{ - // XXX 2.5: this crashes combined with previewrender - // due to global R so disabled for now -#if 0 - /* XXX ugly global still, but we can't do preview while rendering */ - if(G.rendering==0) { - - Render *re= RE_GetRender("_Shade View_"); - if(re==NULL) { - re= RE_NewRender("_Shade View_"); - - RE_Database_Baking(re, scene, 0, 0); /* 0= no faces */ - } - return re; - } -#endif - - return NULL; -} - -/* called on file reading */ -void fastshade_free_render(void) -{ - Render *re= RE_GetRender("_Shade View_"); - - if(re) { - RE_Database_Free(re); - RE_FreeRender(re); - } -} - - -static void fastshade_customdata(CustomData *fdata, int a, int j, Material *ma) -{ - CustomDataLayer *layer; - MTFace *mtface; - int index, needuv= ma->texco & TEXCO_UV; - char *vertcol; - - shi.totuv= 0; - shi.totcol= 0; - - for(index=0; index<fdata->totlayer; index++) { - layer= &fdata->layers[index]; - - if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) { - mtface= &((MTFace*)layer->data)[a]; - - shi.uv[shi.totuv].uv[0]= 2.0f*mtface->uv[j][0]-1.0f; - shi.uv[shi.totuv].uv[1]= 2.0f*mtface->uv[j][1]-1.0f; - shi.uv[shi.totuv].uv[2]= 1.0f; - - shi.uv[shi.totuv].name= layer->name; - shi.totuv++; - } - else if(layer->type == CD_MCOL && shi.totcol < MAX_MCOL) { - vertcol= (char*)&((MCol*)layer->data)[a*4 + j]; - - shi.col[shi.totcol].col[0]= ((float)vertcol[3])/255.0f; - shi.col[shi.totcol].col[1]= ((float)vertcol[2])/255.0f; - shi.col[shi.totcol].col[2]= ((float)vertcol[1])/255.0f; - - shi.col[shi.totcol].name= layer->name; - shi.totcol++; - } - } - - if(needuv && shi.totuv == 0) - VECCOPY(shi.uv[0].uv, shi.lo); - - if(shi.totcol) - VECCOPY(shi.vcol, shi.col[0].col); -} - -static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2) -{ - ShadeResult shr; - int a; - - VECCOPY(shi.co, co); - shi.vn[0]= -nor[0]; - shi.vn[1]= -nor[1]; - shi.vn[2]= -nor[2]; - VECCOPY(shi.vno, shi.vn); - VECCOPY(shi.facenor, shi.vn); - - if(ma->texco) { - VECCOPY(shi.lo, orco); - - if(ma->texco & TEXCO_GLOB) { - VECCOPY(shi.gl, shi.lo); - } - if(ma->texco & TEXCO_WINDOW) { - VECCOPY(shi.winco, shi.lo); - } - if(ma->texco & TEXCO_STICKY) { - VECCOPY(shi.sticky, shi.lo); - } - if(ma->texco & TEXCO_OBJECT) { - VECCOPY(shi.co, shi.lo); - } - if(ma->texco & TEXCO_NORM) { - VECCOPY(shi.orn, shi.vn); - } - if(ma->texco & TEXCO_REFL) { - float inp= 2.0f * (shi.vn[2]); - shi.ref[0]= (inp*shi.vn[0]); - shi.ref[1]= (inp*shi.vn[1]); - shi.ref[2]= (-1.0f + inp*shi.vn[2]); - } - } - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col1[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col1[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col1[2]= CLAMPIS(a, 0, 255); - - if(col2) { - shi.vn[0]= -shi.vn[0]; - shi.vn[1]= -shi.vn[1]; - shi.vn[2]= -shi.vn[2]; - - shi.mat= ma; /* set each time... node shaders change it */ - RE_shade_external(NULL, &shi, &shr); - - a= 256.0f*(shr.combined[0]); - col2[0]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[1]); - col2[1]= CLAMPIS(a, 0, 255); - a= 256.0f*(shr.combined[2]); - col2[2]= CLAMPIS(a, 0, 255); - } -} - -static void init_fastshade_for_ob(Render *re, Object *ob, int *need_orco_r, float mat[4][4], float imat[3][3]) -{ - float tmat[4][4]; - float amb[3]= {0.0f, 0.0f, 0.0f}; - int a; - - /* initialize globals in render */ - RE_shade_external(re, NULL, NULL); - - /* initialize global here */ - init_fastshade_shadeinput(re); - - RE_DataBase_GetView(re, tmat); - mul_m4_m4m4(mat, ob->obmat, tmat); - - invert_m4_m4(tmat, mat); - copy_m3_m4(imat, tmat); - if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0); - - if (need_orco_r) *need_orco_r= 0; - for(a=0; a<ob->totcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) { - init_render_material(ma, 0, amb); - - if(ma->texco & TEXCO_ORCO) { - if (need_orco_r) *need_orco_r= 1; - } - } - } -} - -static void end_fastshade_for_ob(Object *ob) -{ - int a; - - for(a=0; a<ob->totcol; a++) { - Material *ma= give_current_material(ob, a+1); - if(ma) - end_render_material(ma); - } -} - - -static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, unsigned int **col1_r, unsigned int **col2_r) -{ - Mesh *me= ob->data; - DerivedMesh *dm; - MVert *mvert; - MFace *mface; - unsigned int *col1, *col2; - float *orco, *vnors, *nors, imat[3][3], mat[4][4], vec[3]; - int a, i, need_orco, totface, totvert; - CustomDataMask dataMask = CD_MASK_BAREMESH | CD_MASK_MCOL - | CD_MASK_MTFACE | CD_MASK_NORMAL; - - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if(need_orco) - dataMask |= CD_MASK_ORCO; - - if (onlyForMesh) - dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask); - else - dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask); - - mvert = dm->getVertArray(dm); - mface = dm->getFaceArray(dm); - nors = dm->getFaceDataArray(dm, CD_NORMAL); - totvert = dm->getNumVerts(dm); - totface = dm->getNumFaces(dm); - orco= dm->getVertDataArray(dm, CD_ORCO); - - if (onlyForMesh) { - col1 = *col1_r; - col2 = NULL; - } else { - *col1_r = col1 = MEM_mallocN(sizeof(*col1)*totface*4, "col1"); - - if (col2_r && (me->flag & ME_TWOSIDED)) - col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2"); - else - col2 = NULL; - - if (col2_r) *col2_r = col2; - } - - /* vertexnormals */ - vnors= MEM_mallocN(totvert*3*sizeof(float), "vnors disp"); - for (a=0; a<totvert; a++) { - MVert *mv = &mvert[a]; - float *vn= &vnors[a*3]; - float xn= mv->no[0]; - float yn= mv->no[1]; - float zn= mv->no[2]; - - /* transpose ! */ - vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn; - vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn; - vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn; - normalize_v3(vn); - } - - for (i=0; i<totface; i++) { - MFace *mf= &mface[i]; - Material *ma= give_current_material(ob, mf->mat_nr+1); - int j, vidx[4], nverts= mf->v4?4:3; - unsigned char *col1base= (unsigned char*) &col1[i*4]; - unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL); - float nor[3], n1[3]; - - if(ma==NULL) ma= &defmaterial; - - vidx[0]= mf->v1; - vidx[1]= mf->v2; - vidx[2]= mf->v3; - vidx[3]= mf->v4; - - if (nors) { - VECCOPY(nor, &nors[i*3]); - } else { - if (mf->v4) - normal_quad_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co, mvert[mf->v4].co); - else - normal_tri_v3( nor,mvert[mf->v1].co, mvert[mf->v2].co, mvert[mf->v3].co); - } - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - for (j=0; j<nverts; j++) { - MVert *mv= &mvert[vidx[j]]; - char *col1= (char*)&col1base[j*4]; - char *col2= (char*)(col2base?&col2base[j*4]:NULL); - float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1; - - mul_v3_m4v3(vec, mat, mv->co); - - mul_v3_v3fl(vec, vn, 0.001f); - - fastshade_customdata(&dm->faceData, i, j, ma); - fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2); - } - } - MEM_freeN(vnors); - - dm->release(dm); - - end_fastshade_for_ob(ob); -} - -void shadeMeshMCol(Scene *scene, Object *ob, Mesh *me) -{ - Render *re= fastshade_get_render(scene); - int a; - char *cp; - unsigned int *mcol= (unsigned int*)me->mcol; - - if(re) { - mesh_create_shadedColors(re, ob, 1, &mcol, NULL); - me->mcol= (MCol*)mcol; - - /* swap bytes */ - for(cp= (char *)me->mcol, a= 4*me->totface; a>0; a--, cp+=4) { - SWAP(char, cp[0], cp[3]); - SWAP(char, cp[1], cp[2]); - } - } -} - -/* has base pointer, to check for layer */ -/* called from drawobject.c */ -void shadeDispList(Scene *scene, Base *base) -{ - Object *ob= base->object; - DispList *dl, *dlob; - Material *ma = NULL; - Render *re; - float imat[3][3], mat[4][4], vec[3]; - float *fp, *nor, n1[3]; - unsigned int *col1; - int a, need_orco; - - re= fastshade_get_render(scene); - if(re==NULL) - return; - - dl = find_displist(&ob->disp, DL_VERTCOL); - if (dl) { - BLI_remlink(&ob->disp, dl); - free_disp_elem(dl); - } - - if(ob->type==OB_MESH) { - dl= MEM_callocN(sizeof(DispList), "displistshade"); - dl->type= DL_VERTCOL; - - mesh_create_shadedColors(re, ob, 0, &dl->col1, &dl->col2); - - /* add dl to ob->disp after mesh_create_shadedColors, because it - might indirectly free ob->disp */ - BLI_addtail(&ob->disp, dl); - } - else { - - init_fastshade_for_ob(re, ob, &need_orco, mat, imat); - - if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - - /* now we need the normals */ - dl= ob->disp.first; - - while(dl) { - dlob= MEM_callocN(sizeof(DispList), "displistshade"); - BLI_addtail(&ob->disp, dlob); - dlob->type= DL_VERTCOL; - dlob->parts= dl->parts; - dlob->nr= dl->nr; - - if(dl->type==DL_INDEX3) { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - } - else { - col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->parts*dl->nr, "col1"); - } - - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - if(dl->type==DL_INDEX3) { - if(dl->nors) { - /* there's just one normal */ - n1[0]= imat[0][0]*dl->nors[0]+imat[0][1]*dl->nors[1]+imat[0][2]*dl->nors[2]; - n1[1]= imat[1][0]*dl->nors[0]+imat[1][1]*dl->nors[1]+imat[1][2]*dl->nors[2]; - n1[2]= imat[2][0]*dl->nors[0]+imat[2][1]*dl->nors[1]+imat[2][2]*dl->nors[2]; - normalize_v3(n1); - - fp= dl->verts; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; - } - } - } - else if(dl->type==DL_SURF) { - if(dl->nors) { - a= dl->nr*dl->parts; - fp= dl->verts; - nor= dl->nors; - - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; nor+= 3; col1++; - } - } - } - dl= dl->next; - } - } - else if(ob->type==OB_MBALL) { - /* there are normals already */ - dl= ob->disp.first; - - while(dl) { - - if(dl->type==DL_INDEX4) { - if(dl->nors) { - if(dl->col1) MEM_freeN(dl->col1); - col1= dl->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1"); - - ma= give_current_material(ob, dl->col+1); - if(ma==NULL) ma= &defmaterial; - - fp= dl->verts; - nor= dl->nors; - - a= dl->nr; - while(a--) { - mul_v3_m4v3(vec, mat, fp); - - /* transpose ! */ - n1[0]= imat[0][0]*nor[0]+imat[0][1]*nor[1]+imat[0][2]*nor[2]; - n1[1]= imat[1][0]*nor[0]+imat[1][1]*nor[1]+imat[1][2]*nor[2]; - n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2]; - normalize_v3(n1); - - fastshade(vec, n1, fp, ma, (char *)col1, NULL); - - fp+= 3; col1++; nor+= 3; - } - } - } - dl= dl->next; - } - } - - end_fastshade_for_ob(ob); - } -} - -/* frees render and shade part of displists */ -/* note: dont do a shade again, until a redraw happens */ -void reshadeall_displist(Scene *scene) -{ - Base *base; - Object *ob; - - fastshade_free_render(); - - for(base= scene->base.first; base; base= base->next) { - ob= base->object; - - if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) - freedisplist(&ob->disp); - - if(base->lay & scene->lay) { - /* Metaballs have standard displist at the Object */ - if(ob->type==OB_MBALL) shadeDispList(scene, base); - } - } -} - /* ****************** make displists ********************* */ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 3a8a2ae9c09..64e374fe4c0 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -32,8 +32,10 @@ */ -#ifdef WITH_PYTHON -#include <Python.h> +#if 0 /* pynodes commented for now */ +# ifdef WITH_PYTHON +# include <Python.h> +# endif #endif #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 16fa1605467..dff62b05bd3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2641,11 +2641,12 @@ void object_handle_update(Scene *scene, Object *ob) #else /* ensure CD_MASK_BAREMESH for now */ EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + unsigned int data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if(em) { - makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */ + makeDerivedMesh(scene, ob, em, data_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); } else - makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH); + makeDerivedMesh(scene, ob, NULL, data_mask); #endif } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index fca8d470dc1..4e3840832bb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1562,8 +1562,7 @@ static void initialize_all_particles(ParticleSimulationData *sim) } } } -/* sets particle to the emitter surface with initial velocity & rotation */ -void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) +void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, float dtime, float cfra) { Object *ob = sim->ob; ParticleSystem *psys = sim->psys; @@ -1575,17 +1574,6 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float q_phase[4]; int p = pa - psys->particles; part=psys->part; - - /* get precise emitter matrix if particle is born */ - if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { - /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ - while(ob) { - BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); - ob = ob->parent; - } - ob = sim->ob; - where_is_object_time(sim->scene, ob, pa->time); - } /* get birth location from object */ if(part->tanfac != 0.f) @@ -1594,7 +1582,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); /* get possible textural influence */ - psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra); + psys_get_texture(sim, pa, &ptex, PAMAP_IVEL, cfra); /* particles live in global space so */ /* let's convert: */ @@ -1654,37 +1642,27 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, mat4_to_quat(rot,ob->obmat); mul_qt_qtqt(r_rot,r_rot,rot); } -#if 0 - } -#endif if(part->phystype==PART_PHYS_BOIDS && pa->boid) { - BoidParticle *bpa = pa->boid; float dvec[3], q[4], mat[3][3]; - copy_v3_v3(pa->state.co,loc); + copy_v3_v3(state->co,loc); /* boids don't get any initial velocity */ - zero_v3(pa->state.vel); + zero_v3(state->vel); /* boids store direction in ave */ if(fabsf(nor[2])==1.0f) { - sub_v3_v3v3(pa->state.ave, loc, ob->obmat[3]); - normalize_v3(pa->state.ave); + sub_v3_v3v3(state->ave, loc, ob->obmat[3]); + normalize_v3(state->ave); } else { - VECCOPY(pa->state.ave, nor); + VECCOPY(state->ave, nor); } - /* and gravity in r_ve */ - bpa->gravity[0] = bpa->gravity[1] = 0.0f; - bpa->gravity[2] = -1.0f; - if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) - && sim->scene->physics_settings.gravity[2]!=0.0f) - bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; /* calculate rotation matrix */ - project_v3_v3v3(dvec, r_vel, pa->state.ave); - sub_v3_v3v3(mat[0], pa->state.ave, dvec); + project_v3_v3v3(dvec, r_vel, state->ave); + sub_v3_v3v3(mat[0], state->ave, dvec); normalize_v3(mat[0]); negate_v3_v3(mat[2], r_vel); normalize_v3(mat[2]); @@ -1692,12 +1670,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* apply rotation */ mat3_to_quat_is_ok( q,mat); - copy_qt_qt(pa->state.rot, q); - - bpa->data.health = part->boids->health; - bpa->data.mode = eBoidMode_InAir; - bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; - bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; + copy_qt_qt(state->rot, q); } else { /* conversion done so now we apply new: */ @@ -1710,7 +1683,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter velocity */ if(dtime != 0.f && part->obfac != 0.f){ - sub_v3_v3v3(vel, loc, pa->state.co); + sub_v3_v3v3(vel, loc, state->co); mul_v3_fl(vel, part->obfac/dtime); } @@ -1747,13 +1720,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, if(part->partfac != 0.f) madd_v3_v3fl(vel, p_vel, part->partfac); - mul_v3_v3fl(pa->state.vel, vel, ptex.ivel); + mul_v3_v3fl(state->vel, vel, ptex.ivel); /* -location from emitter */ - copy_v3_v3(pa->state.co,loc); + copy_v3_v3(state->co,loc); /* -rotation */ - unit_qt(pa->state.rot); + unit_qt(state->rot); if(part->rotmode){ /* create vector into which rotation is aligned */ @@ -1793,32 +1766,74 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ - mul_qt_qtqt(pa->state.rot, rot, q_phase); + mul_qt_qtqt(state->rot, rot, q_phase); } /* -angular velocity */ - zero_v3(pa->state.ave); + zero_v3(state->ave); if(part->avemode){ switch(part->avemode){ case PART_AVE_SPIN: - copy_v3_v3(pa->state.ave, vel); + copy_v3_v3(state->ave, vel); break; case PART_AVE_RAND: - copy_v3_v3(pa->state.ave, r_ave); + copy_v3_v3(state->ave, r_ave); break; } - normalize_v3(pa->state.ave); - mul_v3_fl(pa->state.ave,part->avefac); + normalize_v3(state->ave); + mul_v3_fl(state->ave, part->avefac); } } +} +/* sets particle to the emitter surface with initial velocity & rotation */ +void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) +{ + Object *ob = sim->ob; + ParticleSystem *psys = sim->psys; + ParticleSettings *part; + ParticleTexture ptex; + int p = pa - psys->particles; + part=psys->part; + + /* get precise emitter matrix if particle is born */ + if(part->type!=PART_HAIR && dtime > 0.f && pa->time < cfra && pa->time >= sim->psys->cfra) { + /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ + while(ob) { + BKE_animsys_evaluate_animdata(&ob->id, ob->adt, pa->time, ADT_RECALC_ANIM); + ob = ob->parent; + } + ob = sim->ob; + where_is_object_time(sim->scene, ob, pa->time); + } + + psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra); + + if(part->phystype==PART_PHYS_BOIDS && pa->boid) { + BoidParticle *bpa = pa->boid; + + /* and gravity in r_ve */ + bpa->gravity[0] = bpa->gravity[1] = 0.0f; + bpa->gravity[2] = -1.0f; + if((sim->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) + && sim->scene->physics_settings.gravity[2]!=0.0f) + bpa->gravity[2] = sim->scene->physics_settings.gravity[2]; + + bpa->data.health = part->boids->health; + bpa->data.mode = eBoidMode_InAir; + bpa->data.state_id = ((BoidState*)part->boids->states.first)->id; + bpa->data.acc[0]=bpa->data.acc[1]=bpa->data.acc[2]=0.0f; + } if(part->type == PART_HAIR){ pa->lifetime = 100.0f; } else{ + /* get possible textural influence */ + psys_get_texture(sim, pa, &ptex, PAMAP_LIFE, cfra); + pa->lifetime = part->lifetime * ptex.life; if(part->randlife != 0.0f) @@ -1904,6 +1919,7 @@ static void set_keyed_keys(ParticleSimulationData *sim) PARTICLE_P; ParticleKey *key; int totpart = psys->totpart, k, totkeys = psys->totkeyed; + int keyed_flag = 0; ksim.scene= sim->scene; @@ -1933,6 +1949,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) for(k=0; k<totkeys; k++) { ksim.ob = pt->ob ? pt->ob : sim->ob; ksim.psys = BLI_findlink(&ksim.ob->particlesystem, pt->psys - 1); + keyed_flag = (ksim.psys->flag & PSYS_KEYED); + ksim.psys->flag &= ~PSYS_KEYED; LOOP_PARTICLES { key = pa->keys + k; @@ -1956,6 +1974,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) if(psys->flag & PSYS_KEYED_TIMING && pt->duration!=0.0f) k++; + ksim.psys->flag |= keyed_flag; + pt = (pt->next && pt->next->flag & PTARGET_VALID)? pt->next : psys->targets.first; } diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 16cef67ea6d..0d523599598 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -430,6 +430,7 @@ void init_actuator(bActuator *act) act->data= MEM_callocN(sizeof(bCameraActuator), "camact"); ca = act->data; ca->axis = ACT_CAMERA_X; + ca->damping = 1.0/32.0; break; case ACT_EDIT_OBJECT: act->data= MEM_callocN(sizeof(bEditObjectActuator), "editobact"); |