diff options
author | Brecht Van Lommel <brecht> | 2020-02-27 13:23:15 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-02-27 17:25:35 +0300 |
commit | f2b95b9eae2ee913c99cff7595527b18d8b49d0a (patch) | |
tree | 4bbd1a009cd5ace8bd9bb3efe8e5882a459b5f98 /source/blender/makesrna | |
parent | 57b7833d1eff5e11bbdec654ff09fb24263cc055 (diff) |
Objects: make evaluated data runtime storage usable for types other than mesh
This is in preparation of new object types. This only changes mesh_eval, we
may do the same for mesh_deform_eval and other areas in the future if there is
a need for it.
Differential Revision: https://developer.blender.org/D6695
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 5552de00be8..cbeb8f17991 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -487,7 +487,7 @@ static Object *eval_object_ensure(Object *ob, ReportList *reports, PointerRNA *rnaptr_depsgraph) { - if (ob->runtime.mesh_eval == NULL) { + if (ob->runtime.data_eval == NULL) { Object *ob_orig = ob; Depsgraph *depsgraph = rnaptr_depsgraph != NULL ? rnaptr_depsgraph->data : NULL; if (depsgraph == NULL) { @@ -496,7 +496,7 @@ static Object *eval_object_ensure(Object *ob, if (depsgraph != NULL) { ob = DEG_get_evaluated_object(depsgraph, ob); } - if (ob == NULL || ob->runtime.mesh_eval == NULL) { + if (ob == NULL || BKE_object_get_evaluated_mesh(ob) == NULL) { BKE_reportf( reports, RPT_ERROR, "Object '%s' has no evaluated mesh data", ob_orig->id.name + 2); return NULL; @@ -521,8 +521,7 @@ static void rna_Object_ray_cast(Object *ob, /* 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 && - (ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { + if ((ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { return; } @@ -538,7 +537,8 @@ static void rna_Object_ray_cast(Object *ob, /* No need to managing allocation or freeing of the BVH data. * This is generated and freed as needed. */ - BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4); + Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob); + BKE_bvhtree_from_mesh_get(&treeData, mesh_eval, BVHTREE_FROM_LOOPTRI, 4); /* may fail if the mesh has no faces, in that case the ray-cast misses */ if (treeData.tree != NULL) { @@ -559,8 +559,7 @@ static void rna_Object_ray_cast(Object *ob, copy_v3_v3(r_location, hit.co); copy_v3_v3(r_normal, hit.no); - *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, - &treeData.looptri[hit.index]); + *r_index = mesh_looptri_to_poly_index(mesh_eval, &treeData.looptri[hit.index]); } } @@ -589,14 +588,14 @@ static void rna_Object_closest_point_on_mesh(Object *ob, { BVHTreeFromMesh treeData = {NULL}; - if (ob->runtime.mesh_eval == NULL && - (ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { + if ((ob = eval_object_ensure(ob, C, reports, rnaptr_depsgraph)) == NULL) { return; } /* No need to managing allocation or freeing of the BVH data. * this is generated and freed as needed. */ - BKE_bvhtree_from_mesh_get(&treeData, ob->runtime.mesh_eval, BVHTREE_FROM_LOOPTRI, 4); + Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob); + BKE_bvhtree_from_mesh_get(&treeData, mesh_eval, BVHTREE_FROM_LOOPTRI, 4); if (treeData.tree == NULL) { BKE_reportf(reports, @@ -617,8 +616,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, copy_v3_v3(r_location, nearest.co); copy_v3_v3(r_normal, nearest.no); - *r_index = mesh_looptri_to_poly_index(ob->runtime.mesh_eval, - &treeData.looptri[nearest.index]); + *r_index = mesh_looptri_to_poly_index(mesh_eval, &treeData.looptri[nearest.index]); goto finally; } @@ -659,8 +657,7 @@ void rna_Object_me_eval_info( switch (type) { case 1: case 2: - if (ob->runtime.mesh_eval == NULL && - (ob = eval_object_ensure(ob, C, NULL, rnaptr_depsgraph)) == NULL) { + if ((ob = eval_object_ensure(ob, C, NULL, rnaptr_depsgraph)) == NULL) { return; } } @@ -675,7 +672,7 @@ void rna_Object_me_eval_info( me_eval = ob->runtime.mesh_deform_eval; break; case 2: - me_eval = ob->runtime.mesh_eval; + me_eval = BKE_object_get_evaluated_mesh(ob); break; } |