Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object_api.c
| Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | static bool rna_Object_indirect_only_get(Object *ob, bContext *C, ViewLayer *view_layer) | ||||
| if (!base) { | if (!base) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| return ((base->flag & BASE_INDIRECT_ONLY) != 0); | return ((base->flag & BASE_INDIRECT_ONLY) != 0); | ||||
| } | } | ||||
| static Base *rna_Object_local_view_property_helper( | static Base *rna_Object_local_view_property_helper(bScreen *sc, | ||||
| bScreen *sc, View3D *v3d, Object *ob, ReportList *reports, Scene **r_scene) | View3D *v3d, | ||||
| ViewLayer *view_layer, | |||||
| Object *ob, | |||||
| ReportList *reports, | |||||
| Scene **r_scene) | |||||
| { | { | ||||
| wmWindow *win = NULL; | |||||
| if (v3d->localvd == NULL) { | if (v3d->localvd == NULL) { | ||||
| BKE_report(reports, RPT_ERROR, "Viewport not in local view"); | BKE_report(reports, RPT_ERROR, "Viewport not in local view"); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| wmWindow *win = ED_screen_window_find(sc, G_MAIN->wm.first); | if (view_layer == NULL) { | ||||
| ViewLayer *view_layer = WM_window_get_active_view_layer(win); | win = ED_screen_window_find(sc, G_MAIN->wm.first); | ||||
| view_layer = WM_window_get_active_view_layer(win); | |||||
| } | |||||
| Base *base = BKE_view_layer_base_find(view_layer, ob); | Base *base = BKE_view_layer_base_find(view_layer, ob); | ||||
| if (base == NULL) { | if (base == NULL) { | ||||
| BKE_reportf( | BKE_reportf( | ||||
| reports, RPT_WARNING, "Object %s not in view layer %s", ob->id.name + 2, view_layer->name); | reports, RPT_WARNING, "Object %s not in view layer %s", ob->id.name + 2, view_layer->name); | ||||
| } | } | ||||
| if (r_scene) { | if (r_scene != NULL && win != NULL) { | ||||
| *r_scene = win->scene; | *r_scene = win->scene; | ||||
| } | } | ||||
| return base; | return base; | ||||
| } | } | ||||
| static bool rna_Object_local_view_get(Object *ob, ReportList *reports, PointerRNA *v3d_ptr) | static bool rna_Object_local_view_get(Object *ob, | ||||
| ReportList *reports, | |||||
| PointerRNA *v3d_ptr, | |||||
| ViewLayer *view_layer) | |||||
| { | { | ||||
| bScreen *sc = (bScreen *)v3d_ptr->owner_id; | bScreen *sc = (bScreen *)v3d_ptr->owner_id; | ||||
jbakker: `blender_python.cpp` seems to be the reason, not the CPP API.
```
PointerRNA v3dptr… | |||||
| View3D *v3d = v3d_ptr->data; | View3D *v3d = v3d_ptr->data; | ||||
| Base *base = rna_Object_local_view_property_helper(sc, v3d, ob, reports, NULL); | Base *base = rna_Object_local_view_property_helper(sc, v3d, view_layer, ob, reports, NULL); | ||||
| if (base == NULL) { | if (base == NULL) { | ||||
| return false; /* Error reported. */ | return false; /* Error reported. */ | ||||
| } | } | ||||
| return (base->local_view_bits & v3d->local_view_uuid) != 0; | return (base->local_view_bits & v3d->local_view_uuid) != 0; | ||||
| } | } | ||||
| static void rna_Object_local_view_set(Object *ob, | static void rna_Object_local_view_set(Object *ob, | ||||
| ReportList *reports, | ReportList *reports, | ||||
| PointerRNA *v3d_ptr, | PointerRNA *v3d_ptr, | ||||
| bool state) | bool state) | ||||
| { | { | ||||
| bScreen *sc = (bScreen *)v3d_ptr->owner_id; | bScreen *sc = (bScreen *)v3d_ptr->owner_id; | ||||
| View3D *v3d = v3d_ptr->data; | View3D *v3d = v3d_ptr->data; | ||||
| Scene *scene; | Scene *scene; | ||||
| Base *base = rna_Object_local_view_property_helper(sc, v3d, ob, reports, &scene); | Base *base = rna_Object_local_view_property_helper(sc, v3d, NULL, ob, reports, &scene); | ||||
| if (base == NULL) { | if (base == NULL) { | ||||
| return; /* Error reported. */ | return; /* Error reported. */ | ||||
| } | } | ||||
| const short local_view_bits_prev = base->local_view_bits; | const short local_view_bits_prev = base->local_view_bits; | ||||
| SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid); | SET_FLAG_FROM_TEST(base->local_view_bits, state, v3d->local_view_uuid); | ||||
| if (local_view_bits_prev != base->local_view_bits) { | if (local_view_bits_prev != base->local_view_bits) { | ||||
| DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); | DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); | ||||
| ScrArea *sa = ED_screen_area_find_with_spacedata(sc, (SpaceLink *)v3d, true); | ScrArea *sa = ED_screen_area_find_with_spacedata(sc, (SpaceLink *)v3d, true); | ||||
| if (sa) { | if (sa) { | ||||
| ED_area_tag_redraw(sa); | ED_area_tag_redraw(sa); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ | /* Convert a given matrix from a space to another (using the object and/or a bone as | ||||
| * reference). */ | |||||
| static void rna_Object_mat_convert_space(Object *ob, | static void rna_Object_mat_convert_space(Object *ob, | ||||
| ReportList *reports, | ReportList *reports, | ||||
| bPoseChannel *pchan, | bPoseChannel *pchan, | ||||
| float *mat, | float *mat, | ||||
| float *mat_ret, | float *mat_ret, | ||||
| int from, | int from, | ||||
| int to) | int to) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | |||||
| /* don't call inside a loop */ | /* don't call inside a loop */ | ||||
| static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt) | static int mesh_looptri_to_poly_index(Mesh *me_eval, const MLoopTri *lt) | ||||
| { | { | ||||
| const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); | const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX); | ||||
| return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly; | return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly; | ||||
| } | } | ||||
| /* TOOD(sergey): Make the Python API more clear that evaluation might happen, or requite passing | /* TOOD(sergey): Make the Python API more clear that evaluation might happen, or requite | ||||
| * fully evaluated depsgraph. */ | * passing fully evaluated depsgraph. */ | ||||
| static Object *eval_object_ensure(Object *ob, | static Object *eval_object_ensure(Object *ob, | ||||
| bContext *C, | bContext *C, | ||||
| ReportList *reports, | ReportList *reports, | ||||
| PointerRNA *rnaptr_depsgraph) | PointerRNA *rnaptr_depsgraph) | ||||
| { | { | ||||
| if (ob->runtime.mesh_eval == NULL) { | if (ob->runtime.mesh_eval == NULL) { | ||||
| Object *ob_orig = ob; | Object *ob_orig = ob; | ||||
| Depsgraph *depsgraph = rnaptr_depsgraph != NULL ? rnaptr_depsgraph->data : NULL; | Depsgraph *depsgraph = rnaptr_depsgraph != NULL ? rnaptr_depsgraph->data : NULL; | ||||
| Show All 21 Lines | static void rna_Object_ray_cast(Object *ob, | ||||
| PointerRNA *rnaptr_depsgraph, | PointerRNA *rnaptr_depsgraph, | ||||
| bool *r_success, | bool *r_success, | ||||
| float r_location[3], | float r_location[3], | ||||
| float r_normal[3], | float r_normal[3], | ||||
| int *r_index) | int *r_index) | ||||
| { | { | ||||
| bool success = false; | bool success = false; | ||||
| /* TODO(sergey): This isn't very reliable check. It is possible to have non-NULL pointer but | /* TODO(sergey): This isn't very reliable check. It is possible to have non-NULL pointer | ||||
| * which is out of date, and possibly dangling one. */ | * but which is out of date, and possibly dangling one. */ | ||||
| if (ob->runtime.mesh_eval == NULL && | if (ob->runtime.mesh_eval == NULL && | ||||
| (ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { | (ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Test BoundBox first (efficiency) */ | /* Test BoundBox first (efficiency) */ | ||||
| BoundBox *bb = BKE_object_boundbox_get(ob); | BoundBox *bb = BKE_object_boundbox_get(ob); | ||||
| float distmin; | float distmin; | ||||
| ▲ Show 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | # endif | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| /* Local View */ | /* Local View */ | ||||
| func = RNA_def_function(srna, "local_view_get", "rna_Object_local_view_get"); | func = RNA_def_function(srna, "local_view_get", "rna_Object_local_view_get"); | ||||
| RNA_def_function_ui_description(func, "Get the local view state for this object"); | RNA_def_function_ui_description(func, "Get the local view state for this object"); | ||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | RNA_def_function_flag(func, FUNC_USE_REPORTS); | ||||
| parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view"); | parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_REQUIRED); | ||||
| parm = RNA_def_pointer(func, | |||||
| "view_layer", | |||||
| "ViewLayer", | |||||
| "", | |||||
| "Optional ViewLayer. Preferably passed for additional performance"); | |||||
Done Inline ActionsRemove . at the end of the description. brecht: Remove `. ` at the end of the description. | |||||
| parm = RNA_def_boolean(func, "result", 0, "", "Object local view state"); | parm = RNA_def_boolean(func, "result", 0, "", "Object local view state"); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "local_view_set", "rna_Object_local_view_set"); | func = RNA_def_function(srna, "local_view_set", "rna_Object_local_view_set"); | ||||
| RNA_def_function_ui_description(func, "Set the local view state for this object"); | RNA_def_function_ui_description(func, "Set the local view state for this object"); | ||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | RNA_def_function_flag(func, FUNC_USE_REPORTS); | ||||
| parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view"); | parm = RNA_def_pointer(func, "viewport", "SpaceView3D", "", "Viewport in local view"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_RNAPTR | PARM_REQUIRED); | ||||
| ▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines | |||||
blender_python.cpp seems to be the reason, not the CPP API.
The first NULL is the reference to the ID datablock where the SpaceView3D is part of. As cycles set it to NULL some parts of the API needs to take some counter measurements. I have also seen this when working on the Viewport Render Parameters.
Will update the patch so BlenderPython also receives the Appropriate Screen. And update the documentation.