Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_ID.c14
-rw-r--r--source/blender/makesrna/intern/rna_context.c29
-rw-r--r--source/blender/makesrna/intern/rna_depsgraph.c15
-rw-r--r--source/blender/makesrna/intern/rna_internal.h5
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c32
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c27
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c22
7 files changed, 59 insertions, 85 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 149cd7caf84..97d3d03468b 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -435,6 +435,11 @@ StructRNA *rna_PropertyGroup_refine(PointerRNA *ptr)
return ptr->type;
}
+static ID *rna_ID_evaluated_get(ID *id, struct Depsgraph *depsgraph)
+{
+ return DEG_get_evaluated_id(depsgraph, id);
+}
+
static ID *rna_ID_copy(ID *id, Main *bmain)
{
ID *newid;
@@ -1446,6 +1451,15 @@ static void rna_def_ID(BlenderRNA *brna)
RNA_def_property_pointer_funcs(prop, "rna_IDPreview_get", NULL, NULL, NULL);
/* functions */
+ func = RNA_def_function(srna, "evaluated_get", "rna_ID_evaluated_get");
+ RNA_def_function_ui_description(
+ func, "Get corresponding evaluated ID from the given dependency graph");
+ parm = RNA_def_pointer(
+ func, "depsgraph", "Depsgraph", "", "Dependency graph to perform lookup in");
+ RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "id", "ID", "", "New copy of the ID");
+ RNA_def_function_return(func, parm);
+
func = RNA_def_function(srna, "copy", "rna_ID_copy");
RNA_def_function_ui_description(
func, "Create a copy of this data-block (not supported for all data-blocks)");
diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c
index 75f8b97b99d..a2ac7cb40ba 100644
--- a/source/blender/makesrna/intern/rna_context.c
+++ b/source/blender/makesrna/intern/rna_context.c
@@ -135,12 +135,6 @@ static PointerRNA rna_Context_main_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_BlendData, CTX_data_main(C));
}
-static PointerRNA rna_Context_depsgraph_get(PointerRNA *ptr)
-{
- bContext *C = (bContext *)ptr->data;
- return rna_pointer_inherit_refine(ptr, &RNA_Depsgraph, CTX_data_depsgraph(C));
-}
-
static PointerRNA rna_Context_scene_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
@@ -204,6 +198,11 @@ static int rna_Context_mode_get(PointerRNA *ptr)
return CTX_data_mode_enum(C);
}
+static struct Depsgraph *rna_Context_evaluated_depsgraph_get(bContext *C)
+{
+ return CTX_data_evaluated_depsgraph(C);
+}
+
#else
void RNA_def_context(BlenderRNA *brna)
@@ -211,6 +210,9 @@ void RNA_def_context(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
srna = RNA_def_struct(brna, "Context", NULL);
RNA_def_struct_ui_text(srna, "Context", "Current windowmanager and data context");
RNA_def_struct_sdna(srna, "bContext");
@@ -267,11 +269,6 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "BlendData");
RNA_def_property_pointer_funcs(prop, "rna_Context_main_get", NULL, NULL, NULL);
- prop = RNA_def_property(srna, "depsgraph", PROP_POINTER, PROP_NONE);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_struct_type(prop, "Depsgraph");
- RNA_def_property_pointer_funcs(prop, "rna_Context_depsgraph_get", NULL, NULL, NULL);
-
prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Scene");
@@ -310,6 +307,16 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_enum_items(prop, rna_enum_context_mode_items);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_enum_funcs(prop, "rna_Context_mode_get", NULL, NULL);
+
+ func = RNA_def_function(srna, "evaluated_depsgraph_get", "rna_Context_evaluated_depsgraph_get");
+ RNA_def_function_ui_description(
+ func,
+ "Get the dependency graph for the current scene and view layer, to access to data-blocks "
+ "with animation and modifiers applied. If any data-blocks have been edited, the dependency "
+ "graph will be updated. This invalidates all references to evaluated data-blocks from the "
+ "dependency graph.");
+ parm = RNA_def_pointer(func, "depsgraph", "Depsgraph", "", "Evaluated dependency graph");
+ RNA_def_function_return(func, parm);
}
#endif
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c
index 447318da744..08f37de26ee 100644
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@ -41,6 +41,7 @@
# include "BKE_anim.h"
# include "BKE_object.h"
+# include "BKE_scene.h"
# include "DEG_depsgraph_build.h"
# include "DEG_depsgraph_debug.h"
@@ -256,6 +257,11 @@ static void rna_Depsgraph_debug_stats(Depsgraph *depsgraph, char *result)
outer);
}
+static void rna_Depsgraph_update(Depsgraph *depsgraph, Main *bmain)
+{
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
+}
+
/* Iteration over objects, simple version */
static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -636,6 +642,15 @@ static void rna_def_depsgraph(BlenderRNA *brna)
RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */
RNA_def_function_output(func, parm);
+ /* Updates. */
+
+ func = RNA_def_function(srna, "update", "rna_Depsgraph_update");
+ RNA_def_function_ui_description(
+ func,
+ "Re-evaluate any modified data-blocks, for example for animation or modifiers. "
+ "This invalidates all references to evaluated data-blocks from this dependency graph.");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
+
/* Queries for original datablockls (the ones depsgraph is built for). */
prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index fc0950c1bb0..d93f8c4414b 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -550,10 +550,7 @@ int rna_parameter_size(struct PropertyRNA *parm);
struct Mesh *rna_Main_meshes_new_from_object(struct Main *bmain,
struct ReportList *reports,
- struct Depsgraph *depsgraph,
- struct Object *ob,
- bool apply_modifiers,
- bool calc_undeformed);
+ struct Object *object);
/* XXX, these should not need to be defined here~! */
struct MTex *rna_mtex_texture_slots_add(struct ID *self,
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index b21cd3324b8..8f48738a27e 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -317,16 +317,9 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name)
}
/* copied from Mesh_getFromObject and adapted to RNA interface */
-Mesh *rna_Main_meshes_new_from_object(Main *bmain,
- ReportList *reports,
- Depsgraph *depsgraph,
- Object *ob,
- bool apply_modifiers,
- bool calc_undeformed)
+Mesh *rna_Main_meshes_new_from_object(Main *bmain, ReportList *reports, Object *object)
{
- Scene *sce = DEG_get_evaluated_scene(depsgraph);
-
- switch (ob->type) {
+ switch (object->type) {
case OB_FONT:
case OB_CURVE:
case OB_SURF:
@@ -338,7 +331,7 @@ Mesh *rna_Main_meshes_new_from_object(Main *bmain,
return NULL;
}
- return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_undeformed);
+ return BKE_mesh_new_from_object(bmain, object);
}
static Light *rna_Main_lights_new(Main *bmain, const char *name, int type)
@@ -951,24 +944,13 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "new_from_object", "rna_Main_meshes_new_from_object");
- RNA_def_function_ui_description(func,
- "Add a new mesh created from object with modifiers applied");
+ RNA_def_function_ui_description(
+ func,
+ "Add a new mesh created from given object (undeformed geometry if object is original, and "
+ "final evaluated geometry, with all modifiers etc., if object is evaluated)");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func,
- "depsgraph",
- "Depsgraph",
- "Dependency Graph",
- "Evaluated dependency graph within which to evaluate modifiers");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_boolean(func,
- "calc_undeformed",
- false,
- "Calculate Undeformed",
- "Calculate undeformed vertex coordinates");
parm = RNA_def_pointer(func,
"mesh",
"Mesh",
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index c997a82f02d..d94abd4066a 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -375,18 +375,11 @@ static void rna_Object_camera_fit_coords(
}
/* copied from Mesh_getFromObject and adapted to RNA interface */
-/* settings: 0 - preview, 1 - render */
-static Mesh *rna_Object_to_mesh(Object *ob,
- bContext *C,
- ReportList *reports,
- Depsgraph *depsgraph,
- bool apply_modifiers,
- bool calc_undeformed)
+static Mesh *rna_Object_to_mesh(Object *object, bContext *C, ReportList *reports)
{
Main *bmain = CTX_data_main(C);
- return rna_Main_meshes_new_from_object(
- bmain, reports, depsgraph, ob, apply_modifiers, calc_undeformed);
+ return rna_Main_meshes_new_from_object(bmain, reports, object);
}
static PointerRNA rna_Object_shape_key_add(
@@ -882,22 +875,10 @@ void RNA_api_object(StructRNA *srna)
/* mesh */
func = RNA_def_function(srna, "to_mesh", "rna_Object_to_mesh");
- RNA_def_function_ui_description(func, "Create a Mesh data-block with modifiers applied");
+ RNA_def_function_ui_description(func,
+ "Create a Mesh data-block from the current state of the object");
RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_CONTEXT);
parm = RNA_def_pointer(func,
- "depsgraph",
- "Depsgraph",
- "Dependency Graph",
- "Evaluated dependency graph within which to evaluate modifiers");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers");
- RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
- RNA_def_boolean(func,
- "calc_undeformed",
- false,
- "Calculate Undeformed",
- "Calculate undeformed vertex coordinates");
- parm = RNA_def_pointer(func,
"mesh",
"Mesh",
"",
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index e29891b60db..1d4d2e9cdd9 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -116,23 +116,6 @@ static void rna_Scene_uvedit_aspect(Scene *scene, Object *ob, float *aspect)
aspect[0] = aspect[1] = 1.0f;
}
-static void rna_Scene_update_tagged(Scene *scene, Main *bmain)
-{
-# ifdef WITH_PYTHON
- BPy_BEGIN_ALLOW_THREADS;
-# endif
-
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer != NULL;
- view_layer = view_layer->next) {
- Depsgraph *depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
- BKE_scene_graph_update_tagged(depsgraph, bmain);
- }
-
-# ifdef WITH_PYTHON
- BPy_END_ALLOW_THREADS;
-# endif
-}
-
static void rna_SceneRender_get_frame_path(
RenderData *rd, Main *bmain, int frame, bool preview, const char *view, char *name)
{
@@ -303,11 +286,6 @@ void RNA_api_scene(StructRNA *srna)
func, "subframe", 0.0, 0.0, 1.0, "", "Sub-frame time, between 0.0 and 1.0", 0.0, 1.0);
RNA_def_function_flag(func, FUNC_USE_MAIN);
- func = RNA_def_function(srna, "update", "rna_Scene_update_tagged");
- RNA_def_function_ui_description(
- func, "Update data tagged to be updated from previous access to data or operators");
- RNA_def_function_flag(func, FUNC_USE_MAIN);
-
func = RNA_def_function(srna, "uvedit_aspect", "rna_Scene_uvedit_aspect");
RNA_def_function_ui_description(func, "Get uv aspect for current object");
parm = RNA_def_pointer(func, "object", "Object", "", "Object");