Depsgraph: Use more const qualifiers

This commit is contained in:
Sergey Sharybin
2018-01-17 12:26:43 +01:00
parent 971a44fe08
commit 333d4f3447
2 changed files with 18 additions and 17 deletions

View File

@@ -53,19 +53,21 @@ extern "C" {
bool DEG_id_type_tagged(struct Main *bmain, short id_type);
/* Get additional evaluation flags for the given ID. */
short DEG_get_eval_flags_for_id(struct Depsgraph *graph, struct ID *id);
short DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
/* Get scene the despgraph is created for. */
struct Scene *DEG_get_evaluated_scene(struct Depsgraph *graph);
struct Scene *DEG_get_evaluated_scene(const struct Depsgraph *graph);
/* Get scene layer the despgraph is created for. */
struct ViewLayer *DEG_get_evaluated_view_layer(struct Depsgraph *graph);
struct ViewLayer *DEG_get_evaluated_view_layer(const struct Depsgraph *graph);
/* Get evaluated version of object for given original one. */
struct Object *DEG_get_evaluated_object(struct Depsgraph *depsgraph, struct Object *object);
struct Object *DEG_get_evaluated_object(const struct Depsgraph *depsgraph,
struct Object *object);
/* Get evaluated version of given ID datablock. */
struct ID *DEG_get_evaluated_id(struct Depsgraph *depsgraph, struct ID *id);
struct ID *DEG_get_evaluated_id(const struct Depsgraph *depsgraph,
struct ID *id);
/* ************************ DEG iterators ********************* */

View File

@@ -53,7 +53,7 @@ bool DEG_id_type_tagged(Main *bmain, short id_type)
return bmain->id_tag_update[BKE_idcode_to_index(id_type)] != 0;
}
short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
short DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
{
if (graph == NULL) {
/* Happens when converting objects to mesh from a python script
@@ -65,9 +65,8 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
return 0;
}
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
const DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
if (id_node == NULL) {
/* TODO(sergey): Does it mean we need to check set scene? */
return 0;
@@ -76,16 +75,16 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
return id_node->eval_flags;
}
Scene *DEG_get_evaluated_scene(Depsgraph *graph)
Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
Scene *scene_orig = deg_graph->scene;
return reinterpret_cast<Scene *>(deg_graph->get_cow_id(&scene_orig->id));
}
ViewLayer *DEG_get_evaluated_view_layer(Depsgraph *graph)
ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
Scene *scene_cow = DEG_get_evaluated_scene(graph);
ViewLayer *view_layer_orig = deg_graph->view_layer;
ViewLayer *view_layer_cow =
@@ -95,19 +94,19 @@ ViewLayer *DEG_get_evaluated_view_layer(Depsgraph *graph)
return view_layer_cow;
}
Object *DEG_get_evaluated_object(Depsgraph *depsgraph, Object *object)
Object *DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
{
return (Object *)DEG_get_evaluated_id(depsgraph, &object->id);
}
ID *DEG_get_evaluated_id(struct Depsgraph *depsgraph, ID *id)
ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
{
/* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(),
* but here we never do assert, since we don't know nature of the
* incoming ID datablock.
*/
DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)depsgraph;
DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
const DEG::Depsgraph *deg_graph = (const DEG::Depsgraph *)depsgraph;
const DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
if (id_node == NULL) {
return id;
}