Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_object_api.c
| Show First 20 Lines • Show All 459 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 | |||||
| * 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; | ||||
| if (depsgraph == NULL) { | if (depsgraph == NULL) { | ||||
| depsgraph = CTX_data_depsgraph(C); | depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| } | } | ||||
| if (depsgraph != NULL) { | if (depsgraph != NULL) { | ||||
| ob = DEG_get_evaluated_object(depsgraph, ob); | ob = DEG_get_evaluated_object(depsgraph, ob); | ||||
| } | } | ||||
| if (ob == NULL || ob->runtime.mesh_eval == NULL) { | if (ob == NULL || ob->runtime.mesh_eval == NULL) { | ||||
| BKE_reportf( | BKE_reportf( | ||||
| reports, RPT_ERROR, "Object '%s' has no evaluated mesh data", ob_orig->id.name + 2); | reports, RPT_ERROR, "Object '%s' has no evaluated mesh data", ob_orig->id.name + 2); | ||||
| return NULL; | return NULL; | ||||
| Show All 11 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 | |||||
| * 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 617 Lines • Show Last 20 Lines | |||||