Changeset View
Standalone View
source/blender/depsgraph/intern/depsgraph_eval.cc
| Show All 40 Lines | |||||
| #include "intern/node/deg_node.h" | #include "intern/node/deg_node.h" | ||||
| #include "intern/node/deg_node_operation.h" | #include "intern/node/deg_node_operation.h" | ||||
| #include "intern/node/deg_node_time.h" | #include "intern/node/deg_node_time.h" | ||||
| #include "intern/depsgraph.h" | #include "intern/depsgraph.h" | ||||
| namespace deg = blender::deg; | namespace deg = blender::deg; | ||||
| /* Evaluate all nodes tagged for updating. */ | /* Evaluate the depsgraph in the given frame. If the depsgraph is already evaluated at that frame, | ||||
| void DEG_evaluate_on_refresh(Depsgraph *graph) | * time-dependend nodes are not recomputed, unless some other dependency changed or | ||||
sybren: I don't understand the 2nd sentence. Why would the caller be responsible for this, if this… | |||||
| * `force_time_refresh` is true. */ | |||||
| static void deg_evaluate(Depsgraph *graph, float new_time, bool force_time_refresh) | |||||
Not Done Inline Actions"in the given frame" is a bit weird, because then a frame is seen as something that has a duration (or something can't be "in" it) rather than a point in time. As it is now, I read it as evaluating the entire interval [frame, frame+1). sybren: "in the given frame" is a bit weird, because then a frame is seen as something that has a… | |||||
| { | { | ||||
Not Done Inline ActionsComments need an update it seems. sergey: Comments need an update it seems. | |||||
| deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); | deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); | ||||
| deg_graph->ctime = BKE_scene_frame_get(deg_graph->scene); | |||||
| /* Update time in scene. */ | const float old_time = deg_graph->ctime; | ||||
| const bool time_changes = old_time != new_time; | |||||
| deg_graph->ctime = new_time; | |||||
| /* Tag time source for update when necessary. */ | |||||
| if (time_changes || force_time_refresh) { | |||||
| deg::TimeSourceNode *time_source = deg_graph->find_time_source(); | |||||
| time_source->tag_update(deg_graph, deg::DEG_UPDATE_SOURCE_TIME); | |||||
| } | |||||
| /* Update the time on the cow scene. */ | |||||
| if (deg_graph->scene_cow) { | if (deg_graph->scene_cow) { | ||||
| BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->ctime); | BKE_scene_frame_set(deg_graph->scene_cow, new_time); | ||||
| } | } | ||||
| deg::deg_graph_flush_updates(deg_graph); | deg::deg_graph_flush_updates(deg_graph); | ||||
| deg::deg_evaluate_on_refresh(deg_graph); | deg::deg_evaluate_on_refresh(deg_graph); | ||||
| deg_graph->need_update_time = false; | |||||
| } | } | ||||
| /* Frame-change happened for root scene that graph belongs to. */ | /* Evaluate all nodes tagged for updating. */ | ||||
| void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime) | void DEG_evaluate_on_refresh(Depsgraph *graph) | ||||
Not Done Inline ActionsThe naming seems to be a bit weird:
So the "on refresh" label blinks in and out of existence, without a clear indication as to why. Also DEG_evaluate_on_refresh() updates the depsgraph time from the scene time, which to me makes sense in a "the frame changed" scenario. But, for that there is a different function DEG_evaluate_on_framechange() function, which actually only sets the time, regardless of what it is in the current scene. Much confusion. Maybe not for this particular patch to solve, but confusing nonetheless. sybren: The naming seems to be a bit weird:
- `DEG_evaluate_on_refresh()` does not call `deg… | |||||
| { | { | ||||
| deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); | const Scene *scene = DEG_get_input_scene(graph); | ||||
| deg_graph->ctime = ctime; | const float time = BKE_scene_frame_get(scene); | ||||
| deg_graph->need_update_time = true; | deg_evaluate(graph, time, false); | ||||
| deg::deg_graph_flush_updates(deg_graph); | |||||
| /* Update time in scene. */ | |||||
| if (deg_graph->scene_cow) { | |||||
| BKE_scene_frame_set(deg_graph->scene_cow, deg_graph->ctime); | |||||
| } | |||||
| /* Perform recalculation updates. */ | |||||
| deg::deg_evaluate_on_refresh(deg_graph); | |||||
| deg_graph->need_update_time = false; | |||||
| } | } | ||||
| bool DEG_needs_eval(Depsgraph *graph) | /* Frame-change happened for root scene that graph belongs to. */ | ||||
| void DEG_evaluate_on_framechange(Depsgraph *graph, float ctime) | |||||
| { | { | ||||
| deg::Depsgraph *deg_graph = reinterpret_cast<deg::Depsgraph *>(graph); | deg_evaluate(graph, ctime, true); | ||||
| return !deg_graph->entry_tags.is_empty() || deg_graph->need_update_time; | |||||
| } | } | ||||
I don't understand the 2nd sentence. Why would the caller be responsible for this, if this function can also figure out whether tagging is necessary or not?
The function seems to do two things:
Probably deg_set_time_and_evaluate would be a better name for the function.