diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_effect.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/effect.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 112 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_dupli.c | 101 |
5 files changed, 26 insertions, 208 deletions
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h index 845c6846708..59284bfadb3 100644 --- a/source/blender/blenkernel/BKE_effect.h +++ b/source/blender/blenkernel/BKE_effect.h @@ -105,7 +105,6 @@ typedef struct EffectorCache { /* precalculated for guides */ struct GuideEffectorData *guide_data; float guide_loc[4], guide_dir[3], guide_radius; - float velocity[3]; float frame; int flag; diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 76647817b88..c7d34480a20 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -159,8 +159,6 @@ struct Base **BKE_object_pose_base_array_get(struct ViewLayer *view_layer, struc void BKE_object_get_parent_matrix( struct Object *ob, struct Object *par, float parentmat[4][4]); -void BKE_object_get_parent_matrix_for_dupli( - struct Object *ob, struct Object *par, float dupli_ctime, int dupli_transflag, float parentmat[4][4]); void BKE_object_where_is_calc( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); void BKE_object_where_is_calc_ex( @@ -168,10 +166,8 @@ void BKE_object_where_is_calc_ex( struct Object *ob, float r_originmat[3][3]); void BKE_object_where_is_calc_time( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime); -void BKE_object_where_is_calc_time_for_dupli( - struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime, int dupli_transflag); void BKE_object_where_is_calc_time_ex( - struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime, int dupli_transflag, + struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float ctime, struct RigidBodyWorld *rbw, float r_originmat[3][3]); void BKE_object_where_is_calc_mat4(struct Object *ob, float obmat[4][4]); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 453d1e70309..e98de4c92f3 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -183,16 +183,6 @@ static void precalculate_effector(struct Depsgraph *depsgraph, EffectorCache *ef } else if (eff->psys) psys_update_particle_tree(eff->psys, ctime); - - /* Store object velocity */ - if (eff->ob) { - float old_vel[3]; - - BKE_object_where_is_calc_time(depsgraph, eff->scene, eff->ob, cfra - 1.0f); - copy_v3_v3(old_vel, eff->ob->obmat[3]); - BKE_object_where_is_calc_time(depsgraph, eff->scene, eff->ob, cfra); - sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel); - } } static void add_effector_relation(ListBase *relations, Object *ob, ParticleSystem *psys, PartDeflect *pd) @@ -690,9 +680,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin copy_v3_v3(efd->loc, ob->obmat[3]); } - if (real_velocity) { - copy_v3_v3(efd->vel, eff->velocity); - } + zero_v3(efd->vel); efd->size = 0.0f; ret = 1; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 4e1ba003228..341a15268ef 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -857,8 +857,6 @@ void BKE_object_init(Object *ob) ob->upflag = OB_POSZ; } - ob->dupon = 1; ob->dupoff = 0; - ob->dupsta = 1; ob->dupend = 100; ob->dupfacesca = 1.0; ob->col_group = 0x01; @@ -1915,8 +1913,7 @@ void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]) * \param depsgraph: Used for dupli-frame time. * \return success if \a mat is set. */ -static bool ob_parcurve(Object *ob, Object *par, - float dupli_ctime, int dupli_transflag, float mat[4][4]) +static bool ob_parcurve(Object *ob, Object *par, float mat[4][4]) { Curve *cu = par->data; float vec[4], dir[3], quat[4], radius, ctime; @@ -1936,29 +1933,19 @@ static bool ob_parcurve(Object *ob, Object *par, return false; } - /* catch exceptions: curve paths used as a duplicator */ - if ((dupli_transflag & OB_DUPLINOSPEED) == 0) { - /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, - * but this will only work if it actually is animated... - * - * we divide the curvetime calculated in the previous step by the length of the path, to get a time - * factor, which then gets clamped to lie within 0.0 - 1.0 range - */ - if (cu->pathlen) { - ctime = cu->ctime / cu->pathlen; - } - else { - ctime = cu->ctime; - } - CLAMP(ctime, 0.0f, 1.0f); + /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, + * but this will only work if it actually is animated... + * + * we divide the curvetime calculated in the previous step by the length of the path, to get a time + * factor, which then gets clamped to lie within 0.0 - 1.0 range + */ + if (cu->pathlen) { + ctime = cu->ctime / cu->pathlen; } else { - ctime = dupli_ctime; - if (cu->pathlen) { - ctime /= cu->pathlen; - } - CLAMP(ctime, 0.0f, 1.0f); + ctime = cu->ctime; } + CLAMP(ctime, 0.0f, 1.0f); unit_m4(mat); @@ -2145,9 +2132,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) } } -void BKE_object_get_parent_matrix_for_dupli(Object *ob, Object *par, - float dupli_ctime, int dupli_transflag, - float parentmat[4][4]) +void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]) { float tmat[4][4]; float vec[3]; @@ -2158,7 +2143,7 @@ void BKE_object_get_parent_matrix_for_dupli(Object *ob, Object *par, ok = 0; if (par->type == OB_CURVE) { if ((((Curve *)par->data)->flag & CU_PATH) && - (ob_parcurve(ob, par, dupli_ctime, dupli_transflag, tmat))) + (ob_parcurve(ob, par, tmat))) { ok = 1; } @@ -2188,20 +2173,13 @@ void BKE_object_get_parent_matrix_for_dupli(Object *ob, Object *par, copy_m4_m4(parentmat, par->obmat); break; } - -} - -void BKE_object_get_parent_matrix(Object *ob, Object *par, float parentmat[4][4]) -{ - BKE_object_get_parent_matrix_for_dupli(ob, par, 0, 0, parentmat); } /** * \param r_originmat: Optional matrix that stores the space the object is in (without its own matrix applied) */ -static void solve_parenting(Object *ob, Object *par, float obmat[4][4], float slowmat[4][4], - float r_originmat[3][3], const bool set_origin, - float dupli_ctime, int dupli_transflag) +static void solve_parenting(Object *ob, Object *par, float obmat[4][4], + float r_originmat[3][3], const bool set_origin) { float totmat[4][4]; float tmat[4][4]; @@ -2209,9 +2187,7 @@ static void solve_parenting(Object *ob, Object *par, float obmat[4][4], float sl BKE_object_to_mat4(ob, locmat); - if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); - - BKE_object_get_parent_matrix_for_dupli(ob, par, dupli_ctime, dupli_transflag, totmat); + BKE_object_get_parent_matrix(ob, par, totmat); /* total */ mul_m4_m4m4(tmat, totmat, ob->parentinv); @@ -2233,29 +2209,9 @@ static void solve_parenting(Object *ob, Object *par, float obmat[4][4], float sl } } -static bool where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4]) -{ - float *fp1, *fp2; - float fac1, fac2; - int a; - - /* include framerate */ - fac1 = (1.0f / (1.0f + fabsf(ob->sf))); - if (fac1 >= 1.0f) return false; - fac2 = 1.0f - fac1; - - fp1 = obmat[0]; - fp2 = slowmat[0]; - for (a = 0; a < 16; a++, fp1++, fp2++) { - fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; - } - - return true; -} - /* note, scene is the active scene while actual_scene is the scene the object resides in */ void BKE_object_where_is_calc_time_ex( - Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime, int dupli_transflag, + Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime, RigidBodyWorld *rbw, float r_originmat[3][3]) { if (ob == NULL) return; @@ -2265,19 +2221,9 @@ void BKE_object_where_is_calc_time_ex( if (ob->parent) { Object *par = ob->parent; - float slowmat[4][4]; /* calculate parent matrix */ - solve_parenting(ob, par, ob->obmat, slowmat, r_originmat, true, - ctime, dupli_transflag); - - /* "slow parent" is definitely not threadsafe, and may also give bad results jumping around - * An old-fashioned hack which probably doesn't really cut it anymore - */ - if (ob->partype & PARSLOW) { - if (!where_is_object_parslow(ob, ob->obmat, slowmat)) - return; - } + solve_parenting(ob, par, ob->obmat, r_originmat, true); } else { BKE_object_to_mat4(ob, ob->obmat); @@ -2303,32 +2249,18 @@ void BKE_object_where_is_calc_time_ex( void BKE_object_where_is_calc_time(Depsgraph *depsgraph, Scene *scene, Object *ob, float ctime) { - BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, 0, NULL, NULL); + BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, NULL, NULL); } -void BKE_object_where_is_calc_time_for_dupli( - Depsgraph *depsgraph, Scene *scene, struct Object *ob, float ctime, int dupli_transflag) -{ - BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, ctime, dupli_transflag, NULL, NULL); -} - - /* get object transformation matrix without recalculating dependencies and * constraints -- assume dependencies are already solved by depsgraph. * no changes to object and it's parent would be done. * used for bundles orientation in 3d space relative to parented blender camera */ void BKE_object_where_is_calc_mat4(Object *ob, float obmat[4][4]) { - if (ob->parent) { - float slowmat[4][4]; - Object *par = ob->parent; - - solve_parenting(ob, par, obmat, slowmat, NULL, false, 0.0f, 0); - - if (ob->partype & PARSLOW) - where_is_object_parslow(ob, obmat, slowmat); + solve_parenting(ob, par, obmat, NULL, false); } else { BKE_object_to_mat4(ob, obmat); @@ -2337,11 +2269,11 @@ void BKE_object_where_is_calc_mat4(Object *ob, float obmat[4][4]) void BKE_object_where_is_calc_ex(Depsgraph *depsgraph, Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3]) { - BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), 0, rbw, r_originmat); + BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), rbw, r_originmat); } void BKE_object_where_is_calc(Depsgraph *depsgraph, Scene *scene, Object *ob) { - BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), 0, NULL, NULL); + BKE_object_where_is_calc_time_ex(depsgraph, scene, ob, DEG_get_ctime(depsgraph), NULL, NULL); } /** diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c index 6cd0f412d06..98eda021d46 100644 --- a/source/blender/blenkernel/intern/object_dupli.c +++ b/source/blender/blenkernel/intern/object_dupli.c @@ -311,74 +311,6 @@ static const DupliGenerator gen_dupli_collection = { make_duplis_collection /* make_duplis */ }; -/* OB_DUPLIFRAMES */ -static void make_duplis_frames(const DupliContext *ctx) -{ - Depsgraph *depsgraph = ctx->depsgraph; - Scene *scene = ctx->scene; - Object *ob = ctx->object; - Object copyob; - int dupend = ob->dupend; - - /* dupliframes not supported inside collections */ - if (ctx->collection) - return; - /* if we don't have any data/settings which will lead to object movement, - * don't waste time trying, as it will all look the same... - */ - if (ob->parent == NULL && BLI_listbase_is_empty(&ob->constraints) && ob->adt == NULL) - return; - - /* make a copy of the object's original data (before any dupli-data overwrites it) - * as we'll need this to keep track of unkeyed data - * - this doesn't take into account other data that can be reached from the object, - * for example it's shapekeys or bones, hence the need for an update flush at the end - */ - copyob = *ob; - - /* duplicate over the required range */ - const int dupli_transflag = (ob->transflag & OB_DUPLINOSPEED); - for (int frame = ob->dupsta; frame <= dupend; frame++) { - int ok = 1; - - /* - dupoff = how often a frames within the range shouldn't be made into duplis - * - dupon = the length of each "skipping" block in frames - */ - if (ob->dupoff) { - ok = frame - ob->dupsta; - ok = ok % (ob->dupon + ob->dupoff); - ok = (ok < ob->dupon); - } - - if (ok) { - /* WARNING: doing animation updates in this way is not terribly accurate, as the dependencies - * and/or other objects which may affect this object's transforms are not updated either. - * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine! - */ - /* ob-eval will do drivers, so we don't need to do them */ - BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, (float)frame, ADT_RECALC_ANIM); - BKE_object_where_is_calc_time_for_dupli(depsgraph, scene, ob, (float)frame, dupli_transflag); - - make_dupli(ctx, ob, ob->obmat, frame); - } - } - - /* ob-eval will do drivers, so we don't need to do them */ - const float original_ctime = DEG_get_ctime(depsgraph); - BKE_animsys_evaluate_animdata(depsgraph, scene, &ob->id, ob->adt, original_ctime, ADT_RECALC_ANIM); - BKE_object_where_is_calc_time(depsgraph, scene, ob, original_ctime); - - /* but, to make sure unkeyed object transforms are still sane, - * let's copy object's original data back over - */ - *ob = copyob; -} - -static const DupliGenerator gen_dupli_frames = { - OB_DUPLIFRAMES, /* type */ - make_duplis_frames /* make_duplis */ -}; - /* OB_DUPLIVERTS */ typedef struct VertexDupliData { Mesh *me_eval; @@ -791,7 +723,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem bool for_render = mode == DAG_EVAL_RENDER; bool use_texcoords = for_render; - Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL; + Object *ob = NULL, **oblist = NULL; DupliObject *dob; ParticleDupliWeight *dw; ParticleSettings *part; @@ -799,7 +731,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem ChildParticle *cpa = NULL; ParticleKey state; ParticleCacheKey *cache; - float ctime, pa_time, scale = 1.0f; + float ctime, scale = 1.0f; float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size = 0.0; float (*obmat)[4]; int a, b, hair = 0; @@ -896,10 +828,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } - /* we also copy the actual objects to restore afterwards, since - * BKE_object_where_is_calc_time will change the object which breaks transform */ oblist = MEM_callocN((size_t)totcollection * sizeof(Object *), "dupcollection object list"); - obcopylist = MEM_callocN((size_t)totcollection * sizeof(Object), "dupcollection copy list"); if (part->draw & PART_DRAW_COUNT_GR) { a = 0; @@ -909,7 +838,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem if (dw->ob == object) { for (b = 0; b < dw->count; b++, a++) { oblist[a] = dw->ob; - obcopylist[a] = *dw->ob; } break; } @@ -922,7 +850,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN(part->dup_group, object, mode) { oblist[a] = object; - obcopylist[a] = *object; a++; } FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; @@ -930,7 +857,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } else { ob = part->dup_ob; - obcopy = *ob; } if (totchild == 0 || part->draw & PART_DRAW_PARENT) @@ -945,7 +871,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem continue; /* pa_num = pa->num; */ /* UNUSED */ - pa_time = pa->time; size = pa->size; } else { @@ -953,7 +878,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem cpa = &psys->child[a - totpart]; /* pa_num = a; */ /* UNUSED */ - pa_time = psys->particles[cpa->parent].time; size = psys_get_child_size(psys, cpa, ctime, NULL); } @@ -1043,9 +967,6 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; } else { - /* to give ipos in object correct offset */ - BKE_object_where_is_calc_time(ctx->depsgraph, scene, ob, ctime - pa_time); - copy_v3_v3(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; @@ -1092,22 +1013,12 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem } } - /* restore objects since they were changed in BKE_object_where_is_calc_time */ - if (part->ren_as == PART_DRAW_GR) { - for (a = 0; a < totcollection; a++) - *(oblist[a]) = obcopylist[a]; - } - else - *ob = obcopy; - BLI_rng_free(rng); } /* clean up */ if (oblist) MEM_freeN(oblist); - if (obcopylist) - MEM_freeN(obcopylist); if (psys->lattice_deform_data) { end_latt_deform(psys->lattice_deform_data); @@ -1164,9 +1075,6 @@ static const DupliGenerator *get_dupli_generator(const DupliContext *ctx) if (ctx->object->type == OB_MESH) return &gen_dupli_faces; } - else if (transflag & OB_DUPLIFRAMES) { - return &gen_dupli_frames; - } else if (transflag & OB_DUPLICOLLECTION) { return &gen_dupli_collection; } @@ -1218,11 +1126,6 @@ int count_duplilist(Object *ob) } } } - else if (ob->transflag & OB_DUPLIFRAMES) { - int tot = ob->dupend - ob->dupsta; - tot /= (ob->dupon + ob->dupoff); - return tot * ob->dupon; - } } return 1; } |