diff options
Diffstat (limited to 'source')
20 files changed, 631 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index a8e430c78df..dc751747f32 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -175,6 +175,9 @@ void BKE_animsys_evaluate_animdata(struct Scene *scene, struct ID *id, struct An /* Evaluation of all ID-blocks with Animation Data blocks - Animation Data Only */ void BKE_animsys_evaluate_all_animation(struct Main *main, struct Scene *scene, float ctime); +/* TODO(sergey): This is mainly a temp public function. */ +struct FCurve; +bool BKE_animsys_execute_fcurve(struct PointerRNA *ptr, struct AnimMapper *remap, struct FCurve *fcu); /* ------------ Specialized API --------------- */ /* There are a few special tools which require these following functions. They are NOT to be used @@ -192,4 +195,13 @@ void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act, /* ************************************* */ +/* ------------ Evaluation API --------------- */ + +struct EvaluationContext; + +void BKE_animsys_eval_animdata(struct EvaluationContext *eval_ctx, struct ID *id); +void BKE_animsys_eval_driver(struct EvaluationContext *eval_ctx, struct ID *id, struct FCurve *fcurve); + +/* ************************************* */ + #endif /* __BKE_ANIMSYS_H__*/ diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index ada07817d31..5bdf360ded2 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -143,10 +143,54 @@ void b_bone_spline_setup(struct bPoseChannel *pchan, int rest, Mat4 result_array (PBONE_VISIBLE(arm, bone) && !((bone)->flag & BONE_UNSELECTABLE)) /* Evaluation helpers */ +struct bKinematicConstraint; +struct bPose; +struct bSplineIKConstraint; +struct EvaluationContext; + +struct bPoseChannel *BKE_armature_ik_solver_find_root(struct bPoseChannel *pchan, + struct bKinematicConstraint *data); +struct bPoseChannel* BKE_armature_splineik_solver_find_root(struct bPoseChannel *pchan, + struct bSplineIKConstraint *data); void BKE_pose_splineik_init_tree(struct Scene *scene, struct Object *ob, float ctime); void BKE_splineik_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan_root, float ctime); +void BKE_pose_eval_init(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct bPose *pose); + +void BKE_pose_eval_bone(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct bPoseChannel *pchan); + +void BKE_pose_constraints_evaluate(struct EvaluationContext *eval_ctx, + struct Object *ob, + struct bPoseChannel *pchan); + +void BKE_pose_bone_done(struct EvaluationContext *eval_ctx, + struct bPoseChannel *pchan); + +void BKE_pose_iktree_evaluate(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct bPoseChannel *rootchan); + +void BKE_pose_splineik_evaluate(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct bPoseChannel *rootchan); + +void BKE_pose_eval_flush(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct bPose *pose); + +void BKE_pose_eval_proxy_copy(struct EvaluationContext *eval_ctx, + struct Object *ob); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 3ecd472f65b..9bae2ad948d 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -184,4 +184,14 @@ void BKE_nurb_handles_autocalc(struct Nurb *nu, int flag); void BKE_nurb_bezt_handle_test(struct BezTriple *bezt, const bool use_handle); void BKE_nurb_handles_test(struct Nurb *nu, const bool use_handles); +/* **** Depsgraph evaluation **** */ + +struct EvaluationContext; + +void BKE_curve_eval_geometry(struct EvaluationContext *eval_ctx, + struct Curve *curve); + +void BKE_curve_eval_path(struct EvaluationContext *eval_ctx, + struct Curve *curve); + #endif /* __BKE_CURVE_H__ */ diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h index 1887a892b2e..f3a483fd0d8 100644 --- a/source/blender/blenkernel/BKE_depsgraph.h +++ b/source/blender/blenkernel/BKE_depsgraph.h @@ -56,6 +56,7 @@ struct Scene; */ typedef struct EvaluationContext { int mode; /* evaluation mode */ + float ctime; /* evaluation time */ } EvaluationContext; typedef enum eEvaluationMode { diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index 5fb1053b53f..4ffdb632513 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -93,4 +93,11 @@ int BKE_lattice_index_flip(struct Lattice *lt, const int index, void BKE_lattice_bitmap_from_flag(struct Lattice *lt, unsigned int *bitmap, const short flag, const bool clear, const bool respecthide); +/* **** Depsgraph evaluation **** */ + +struct EvaluationContext; + +void BKE_lattice_eval_geometry(struct EvaluationContext *eval_ctx, + struct Lattice *latt); + #endif /* __BKE_LATTICE_H__ */ diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 321cbbbd708..62cd50099fd 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -68,4 +68,11 @@ void BKE_mball_select_all(struct MetaBall *mb); void BKE_mball_deselect_all(struct MetaBall *mb); void BKE_mball_select_swap(struct MetaBall *mb); +/* **** Depsgraph evaluation **** */ + +struct EvaluationContext; + +void BKE_mball_eval_geometry(struct EvaluationContext *eval_ctx, + struct MetaBall *mball); + #endif diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index ebf4384d5a7..570c99b7bd9 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -360,6 +360,13 @@ void BKE_mesh_strip_loose_edges(struct Mesh *me); void BKE_mesh_calc_edges_legacy(struct Mesh *me, const bool use_old); void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select); +/* **** Depsgraph evaluation **** */ + +struct EvaluationContext; + +void BKE_mesh_eval_geometry(struct EvaluationContext *eval_ctx, + struct Mesh *mesh); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index c270ebbda7d..7502db21132 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -181,6 +181,28 @@ void BKE_object_tfm_protected_restore(struct Object *ob, const short protectflag); /* Dependency graph evaluation callbacks. */ +void BKE_object_eval_local_transform(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); +void BKE_object_eval_parent(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); +void BKE_object_eval_constraints(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); +void BKE_object_eval_done(struct EvaluationContext *eval_ctx, struct Object *ob); + +void BKE_object_eval_modifier(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct ModifierData *md); +void BKE_object_eval_uber_transform(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); +void BKE_object_eval_uber_data(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); + void BKE_object_handle_data_update(struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 27eeb09c58c..e03789f502b 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -459,4 +459,12 @@ typedef struct ParticleRenderData { #define DMCACHE_NOTFOUND -1 #define DMCACHE_ISCHILD -2 +/* **** Depsgraph evaluation **** */ + +struct EvaluationContext; + +void BKE_particle_system_eval(struct EvaluationContext *eval_ctx, + struct Object *ob, + struct ParticleSystem *psys); + #endif diff --git a/source/blender/blenkernel/BKE_rigidbody.h b/source/blender/blenkernel/BKE_rigidbody.h index 0ae240e1f6b..b327f0c2574 100644 --- a/source/blender/blenkernel/BKE_rigidbody.h +++ b/source/blender/blenkernel/BKE_rigidbody.h @@ -98,4 +98,19 @@ void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw); void BKE_rigidbody_rebuild_world(struct Scene *scene, float ctime); void BKE_rigidbody_do_simulation(struct Scene *scene, float ctime); +/* -------------------- */ +/* Depsgraph evaluation */ + +struct EvaluationContext; + +void BKE_rigidbody_rebuild_sim(struct EvaluationContext *eval_ctx, + struct Scene *scene); + +void BKE_rigidbody_eval_simulation(struct EvaluationContext *eval_ctx, + struct Scene *scene); + +void BKE_rigidbody_object_sync_transforms(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob); + #endif /* __BKE_RIGIDBODY_H__ */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 3c98d11dbdb..d5a8b8f857c 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1620,7 +1620,7 @@ static bool animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_ind } /* Simple replacement based data-setting of the FCurve using RNA */ -static bool animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu) +bool BKE_animsys_execute_fcurve(PointerRNA *ptr, AnimMapper *remap, FCurve *fcu) { char *path = NULL; bool free_path = false; @@ -1655,7 +1655,7 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr, ListBase *list, AnimMapper /* check if this curve should be skipped */ if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) { calculate_fcurve(fcu, ctime); - animsys_execute_fcurve(ptr, remap, fcu); + BKE_animsys_execute_fcurve(ptr, remap, fcu); } } } @@ -1685,7 +1685,7 @@ static void animsys_evaluate_drivers(PointerRNA *ptr, AnimData *adt, float ctime * NOTE: for 'layering' option later on, we should check if we should remove old value before adding * new to only be done when drivers only changed */ calculate_fcurve(fcu, ctime); - ok = animsys_execute_fcurve(ptr, NULL, fcu); + ok = BKE_animsys_execute_fcurve(ptr, NULL, fcu); /* clear recalc flag */ driver->flag &= ~DRIVER_FLAG_RECALC; @@ -1754,7 +1754,7 @@ void animsys_evaluate_action_group(PointerRNA *ptr, bAction *act, bActionGroup * /* check if this curve should be skipped */ if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) { calculate_fcurve(fcu, ctime); - animsys_execute_fcurve(ptr, remap, fcu); + BKE_animsys_execute_fcurve(ptr, remap, fcu); } } } @@ -2846,3 +2846,62 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime) } /* ***************************************** */ + +/* ************** */ +/* Evaluation API */ + +#define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf + +void BKE_animsys_eval_animdata(EvaluationContext *eval_ctx, ID *id) +{ + AnimData *adt = BKE_animdata_from_id(id); + Scene *scene = NULL; /* XXX: this is only needed for flushing RNA updates, + * which should get handled as part of the graph instead... + */ + DEBUG_PRINT("%s on %s, time=%f\n\n", __func__, id->name, (double)eval_ctx->ctime); + BKE_animsys_evaluate_animdata(scene, id, adt, eval_ctx->ctime, ADT_RECALC_ANIM); +} + +void BKE_animsys_eval_driver(EvaluationContext *eval_ctx, + ID *id, + FCurve *fcu) +{ + /* TODO(sergey): De-duplicate with BKE animsys. */ + ChannelDriver *driver = fcu->driver; + PointerRNA id_ptr; + bool ok = false; + + DEBUG_PRINT("%s on %s (%s[%d])\n", + __func__, + id->name, + fcu->rna_path, + fcu->array_index); + + RNA_id_pointer_create(id, &id_ptr); + + /* check if this driver's curve should be skipped */ + if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) { + /* check if driver itself is tagged for recalculation */ + /* XXX driver recalc flag is not set yet by depsgraph! */ + if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) { + /* evaluate this using values set already in other places + * NOTE: for 'layering' option later on, we should check if we should remove old value before adding + * new to only be done when drivers only changed */ + //printf("\told val = %f\n", fcu->curval); + calculate_fcurve(fcu, eval_ctx->ctime); + ok = BKE_animsys_execute_fcurve(&id_ptr, NULL, fcu); + //printf("\tnew val = %f\n", fcu->curval); + + /* clear recalc flag */ + driver->flag &= ~DRIVER_FLAG_RECALC; + + /* set error-flag if evaluation failed */ + if (ok == 0) { + printf("invalid driver - %s[%d]\n", fcu->rna_path, fcu->array_index); + driver->flag |= DRIVER_FLAG_INVALID; + } + } + } +} + +#undef DEBUG_PRINT diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index d5416b41b44..498609e62ea 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1825,9 +1825,12 @@ void BKE_pose_rebuild(Object *ob, bArmature *arm) BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */ +#ifdef WITH_LEGACY_DEPSGRAPH /* the sorting */ + /* Sorting for new dependnecy graph is done on the scene graph level. */ if (counter > 1) DAG_pose_sort(ob); +#endif ob->pose->flag &= ~POSE_RECALC; ob->pose->flag |= POSE_WAS_REBUILT; @@ -2215,3 +2218,44 @@ BoundBox *BKE_armature_boundbox_get(Object *ob) return ob->bb; } + +/************** Graph evaluation ********************/ + +bPoseChannel *BKE_armature_ik_solver_find_root(bPoseChannel *pchan, + bKinematicConstraint *data) +{ + bPoseChannel *rootchan = pchan; + if (!(data->flag & CONSTRAINT_IK_TIP)) { + /* Exclude tip from chain. */ + rootchan = rootchan->parent; + } + if (rootchan != NULL) { + int segcount = 0; + while (rootchan->parent) { + /* Continue up chain, until we reach target number of items. */ + segcount++; + if (segcount == data->rootbone) { + break; + } + rootchan = rootchan->parent; + } + } + return rootchan; +} + +bPoseChannel* BKE_armature_splineik_solver_find_root(bPoseChannel *pchan, + bSplineIKConstraint *data) +{ + bPoseChannel *rootchan = pchan; + int segcount = 0; + BLI_assert(rootchan != NULL); + while (rootchan->parent) { + /* Continue up chain, until we reach target number of items. */ + segcount++; + if (segcount == data->chainlen) { + break; + } + rootchan = rootchan->parent; + } + return rootchan; +} diff --git a/source/blender/blenkernel/intern/armature_update.c b/source/blender/blenkernel/intern/armature_update.c index f7aee3fa2d4..44ffb6a6697 100644 --- a/source/blender/blenkernel/intern/armature_update.c +++ b/source/blender/blenkernel/intern/armature_update.c @@ -51,6 +51,12 @@ #include "BKE_global.h" #include "BKE_main.h" +#ifdef WITH_LEGACY_DEPSGRAPH +# define DEBUG_PRINT if (!DEG_depsgraph_use_legacy() && G.debug & G_DEBUG_DEPSGRAPH) printf +#else +# define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf +#endif + /* ********************** SPLINE IK SOLVER ******************* */ /* Temporary evaluation tree data used for Spline IK */ @@ -547,3 +553,143 @@ void BKE_splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_roo { splineik_execute_tree(scene, ob, pchan_root, ctime); } + +/* *************** Depsgraph evaluation callbacks ************ */ + +void BKE_pose_eval_init(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob, + bPose *pose) +{ + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ + bPoseChannel *pchan; + + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + + BLI_assert(ob->type == OB_ARMATURE); + + /* We demand having proper pose. */ + BLI_assert(ob->pose != NULL); + BLI_assert((ob->pose->flag & POSE_RECALC) == 0); + + /* imat is needed for solvers. */ + invert_m4_m4(ob->imat, ob->obmat); + + /* 1. clear flags */ + for (pchan = pose->chanbase.first; pchan != NULL; pchan = pchan->next) { + pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE); + } + + /* 2a. construct the IK tree (standard IK) */ + BIK_initialize_tree(scene, ob, ctime); + + /* 2b. construct the Spline IK trees + * - this is not integrated as an IK plugin, since it should be able + * to function in conjunction with standard IK + */ + BKE_pose_splineik_init_tree(scene, ob, ctime); +} + +void BKE_pose_eval_bone(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob, + bPoseChannel *pchan) +{ + bArmature *arm = (bArmature *)ob->data; + DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, pchan->name); + BLI_assert(ob->type == OB_ARMATURE); + if (arm->edbo || (arm->flag & ARM_RESTPOS)) { + Bone *bone = pchan->bone; + if (bone) { + copy_m4_m4(pchan->pose_mat, bone->arm_mat); + copy_v3_v3(pchan->pose_head, bone->arm_head); + copy_v3_v3(pchan->pose_tail, bone->arm_tail); + } + } + else { + /* TODO(sergey): Currently if there are constraints full transform is being + * evaluated in BKE_pose_constraints_evaluate. + */ + if (pchan->constraints.first == NULL) { + if (pchan->flag & POSE_IKTREE || pchan->flag & POSE_IKSPLINE) { + /* pass */ + } + else { + /* TODO(sergey): Use time source node for time. */ + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + } + } + } +} + +void BKE_pose_constraints_evaluate(EvaluationContext *UNUSED(eval_ctx), + Object *ob, + bPoseChannel *pchan) +{ + Scene *scene = (Scene*)G.main->scene.first; + DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, pchan->name); + if (pchan->flag & POSE_IKTREE || pchan->flag & POSE_IKSPLINE) { + /* IK are being solved separately/ */ + } + else { + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + } +} + +void BKE_pose_bone_done(EvaluationContext *UNUSED(eval_ctx), + bPoseChannel *pchan) +{ + float imat[4][4]; + DEBUG_PRINT("%s on pchan %s\n", __func__, pchan->name); + if (pchan->bone) { + invert_m4_m4(imat, pchan->bone->arm_mat); + mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat); + } +} + +void BKE_pose_iktree_evaluate(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob, + bPoseChannel *rootchan) +{ + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ + DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name); + BIK_execute_tree(scene, ob, rootchan, ctime); +} + +void BKE_pose_splineik_evaluate(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob, + bPoseChannel *rootchan) +{ + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ + DEBUG_PRINT("%s on %s pchan %s\n", __func__, ob->id.name, rootchan->name); + BKE_splineik_execute_tree(scene, ob, rootchan, ctime); +} + +void BKE_pose_eval_flush(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob, + bPose *UNUSED(pose)) +{ + float ctime = BKE_scene_frame_get(scene); /* not accurate... */ + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + BLI_assert(ob->type == OB_ARMATURE); + + /* 6. release the IK tree */ + BIK_release_tree(scene, ob, ctime); + + ob->recalc &= ~OB_RECALC_ALL; +} + +void BKE_pose_eval_proxy_copy(EvaluationContext *UNUSED(eval_ctx), Object *ob) +{ + BLI_assert(ob->id.lib != NULL && ob->proxy_from != NULL); + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) { + printf("Proxy copy error, lib Object: %s proxy Object: %s\n", + ob->id.name + 2, ob->proxy_from->id.name + 2); + } +} diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index c27460b81c0..c95b0055683 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -4563,3 +4563,27 @@ void BKE_curve_rect_from_textbox(const struct Curve *cu, const struct TextBox *t r_rect->xmax = r_rect->xmin + tb->w; r_rect->ymin = r_rect->ymax - tb->h; } + +/* **** Depsgraph evaluation **** */ + +void BKE_curve_eval_geometry(EvaluationContext *UNUSED(eval_ctx), + Curve *curve) +{ + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s on %s\n", __func__, curve->id.name); + } + if (curve->bb == NULL || (curve->bb->flag & BOUNDBOX_DIRTY)) { + BKE_curve_texspace_calc(curve); + } +} + +void BKE_curve_eval_path(EvaluationContext *UNUSED(eval_ctx), + Curve *curve) +{ + /* TODO(sergey): This will probably need to be a part of + * the modifier stack still. + */ + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s on %s\n", __func__, curve->id.name); + } +} diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 73dca9436ef..86927609ff6 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -53,6 +53,7 @@ #include "BKE_anim.h" #include "BKE_cdderivedmesh.h" #include "BKE_curve.h" +#include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_global.h" #include "BKE_key.h" @@ -1206,3 +1207,10 @@ void BKE_lattice_translate(Lattice *lt, float offset[3], bool do_keys) } } +/* **** Depsgraph evaluation **** */ + +void BKE_lattice_eval_geometry(EvaluationContext *UNUSED(eval_ctx), + Lattice *UNUSED(latt)) +{ +} + diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 8728e6f98d5..c09cd1aabdc 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -586,3 +586,9 @@ void BKE_mball_select_swap(struct MetaBall *mb) } } +/* **** Depsgraph evaluation **** */ + +void BKE_mball_eval_geometry(EvaluationContext *UNUSED(eval_ctx), + MetaBall *UNUSED(mball)) +{ +} diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index e66a4d48fc8..735e4358cb8 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -2523,3 +2523,15 @@ Mesh *BKE_mesh_new_from_object( return tmpmesh; } +/* **** Depsgraph evaluation **** */ + +void BKE_mesh_eval_geometry(EvaluationContext *UNUSED(eval_ctx), + Mesh *mesh) +{ + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s on %s\n", __func__, mesh->id.name); + } + if (mesh->bb == NULL || (mesh->bb->flag & BOUNDBOX_DIRTY)) { + BKE_mesh_texspace_calc(mesh); + } +} diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 196c85831e0..76c20adf8c5 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -57,6 +57,100 @@ #include "BKE_material.h" #include "BKE_image.h" +#ifdef WITH_LEGACY_DEPSGRAPH +# define DEBUG_PRINT if (!DEG_depsgraph_use_legacy() && G.debug & G_DEBUG_DEPSGRAPH) printf +#else +# define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf +#endif + +void BKE_object_eval_local_transform(EvaluationContext *UNUSED(eval_ctx), + Scene *UNUSED(scene), + Object *ob) +{ + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + + /* calculate local matrix */ + BKE_object_to_mat4(ob, ob->obmat); +} + +/* Evaluate parent */ +/* NOTE: based on solve_parenting(), but with the cruft stripped out */ +void BKE_object_eval_parent(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob) +{ + Object *par = ob->parent; + + float totmat[4][4]; + float tmat[4][4]; + float locmat[4][4]; + + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + + /* get local matrix (but don't calculate it, as that was done already!) */ + // XXX: redundant? + copy_m4_m4(locmat, ob->obmat); + + /* get parent effect matrix */ + BKE_object_get_parent_matrix(scene, ob, par, totmat); + + /* total */ + mul_m4_m4m4(tmat, totmat, ob->parentinv); + mul_m4_m4m4(ob->obmat, tmat, locmat); + + /* origin, for help line */ + if ((ob->partype & PARTYPE) == PARSKEL) { + copy_v3_v3(ob->orig, par->obmat[3]); + } + else { + copy_v3_v3(ob->orig, totmat[3]); + } +} + +void BKE_object_eval_constraints(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob) +{ + bConstraintOb *cob; + float ctime = BKE_scene_frame_get(scene); + + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + + /* evaluate constraints stack */ + /* TODO: split this into: + * - pre (i.e. BKE_constraints_make_evalob, per-constraint (i.e. + * - inner body of BKE_constraints_solve), + * - post (i.e. BKE_constraints_clear_evalob) + * + * Not sure why, this is from Joshua - sergey + * + */ + cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + BKE_constraints_solve(&ob->constraints, cob, ctime); + BKE_constraints_clear_evalob(cob); +} + +void BKE_object_eval_done(EvaluationContext *UNUSED(eval_ctx), Object *ob) +{ + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + + /* Set negative scale flag in object. */ + if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; + else ob->transflag &= ~OB_NEG_SCALE; +} + +void BKE_object_eval_modifier(struct EvaluationContext *eval_ctx, + struct Scene *scene, + struct Object *ob, + struct ModifierData *md) +{ + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + (void) eval_ctx; /* Ignored. */ + (void) scene; /* Ignored. */ + (void) ob; /* Ignored. */ + (void) md; /* Ignored. */ +} + void BKE_object_handle_data_update(EvaluationContext *eval_ctx, Scene *scene, Object *ob) @@ -202,3 +296,43 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx, /* quick cache removed */ } + +void BKE_object_eval_uber_transform(EvaluationContext *UNUSED(eval_ctx), + Scene *UNUSED(scene), + Object *ob) +{ + /* TODO(sergey): Currently it's a duplicate of logic in BKE_object_handle_update_ex(). */ + // XXX: it's almost redundant now... + + /* Handle proxy copy for target, */ + if (ob->id.lib && ob->proxy_from) { + if (ob->proxy_from->proxy_group) { + /* Transform proxy into group space. */ + Object *obg = ob->proxy_from->proxy_group; + invert_m4_m4(obg->imat, obg->obmat); + mul_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat); + /* Should always be true. */ + if (obg->dup_group) { + add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs); + } + } + else + copy_m4_m4(ob->obmat, ob->proxy_from->obmat); + } + + ob->recalc &= ~(OB_RECALC_OB|OB_RECALC_TIME); + if (ob->data == NULL) { + ob->recalc &= ~OB_RECALC_DATA; + } +} + +void BKE_object_eval_uber_data(EvaluationContext *eval_ctx, + Scene *scene, + Object *ob) +{ + DEBUG_PRINT("%s on %s\n", __func__, ob->id.name); + BLI_assert(ob->type != OB_ARMATURE); + BKE_object_handle_data_update(eval_ctx, scene, ob); + + ob->recalc &= ~(OB_RECALC_DATA|OB_RECALC_TIME); +} diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 4bc46a476a5..3a19ca7304c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -90,6 +90,7 @@ #include "BKE_modifier.h" #include "BKE_scene.h" #include "BKE_bvhutils.h" +#include "BKE_depsgraph.h" #include "PIL_time.h" @@ -4209,3 +4210,13 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) invert_m4_m4(psys->imat, ob->obmat); } +/* **** Depsgraph evaluation **** */ + +void BKE_particle_system_eval(EvaluationContext *UNUSED(eval_ctx), + Object *ob, + ParticleSystem *psys) +{ + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s on %s:%s\n", __func__, ob->id.name, psys->name); + } +} diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index aaf54b82f32..ff9e1a2b831 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -54,6 +54,7 @@ #include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" +#include "BKE_depsgraph.h" #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_library.h" @@ -61,6 +62,7 @@ #include "BKE_object.h" #include "BKE_pointcache.h" #include "BKE_rigidbody.h" +#include "BKE_scene.h" #ifdef WITH_BULLET @@ -1610,3 +1612,51 @@ void BKE_rigidbody_do_simulation(Scene *scene, float ctime) {} #endif #endif /* WITH_BULLET */ + +/* -------------------- */ +/* Depsgraph evaluation */ + +void BKE_rigidbody_rebuild_sim(EvaluationContext *UNUSED(eval_ctx), + Scene *scene) +{ + float ctime = BKE_scene_frame_get(scene); + + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s at %f\n", __func__, ctime); + } + + /* rebuild sim data (i.e. after resetting to start of timeline) */ + if (BKE_scene_check_rigidbody_active(scene)) { + BKE_rigidbody_rebuild_world(scene, ctime); + } +} + +void BKE_rigidbody_eval_simulation(EvaluationContext *UNUSED(eval_ctx), + Scene *scene) +{ + float ctime = BKE_scene_frame_get(scene); + + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s at %f\n", __func__, ctime); + } + + /* evaluate rigidbody sim */ + if (BKE_scene_check_rigidbody_active(scene)) { + BKE_rigidbody_do_simulation(scene, ctime); + } +} + +void BKE_rigidbody_object_sync_transforms(EvaluationContext *UNUSED(eval_ctx), + Scene *scene, + Object *ob) +{ + RigidBodyWorld *rbw = scene->rigidbody_world; + float ctime = BKE_scene_frame_get(scene); + + if (G.debug & G_DEBUG_DEPSGRAPH) { + printf("%s on %s\n", __func__, ob->id.name); + } + + /* read values pushed into RBO from sim/cache... */ + BKE_rigidbody_sync_transforms(rbw, ob, ctime); +} |