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:
authorCampbell Barton <ideasman42@gmail.com>2013-08-06 06:16:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-06 06:16:29 +0400
commit2acf6e9d841c7d813c21bcc37ffcbeaa8cfa1d2a (patch)
tree7c0fc1c4b9600a007ab0b993f1cd371255e0a16c /source/blender/makesrna/intern/rna_object_api.c
parent98176b4e1e2e0e06208bff02c21595fcd678c358 (diff)
fix [#36363] ray_cast face index with n_gons
Diffstat (limited to 'source/blender/makesrna/intern/rna_object_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index a4e532660f1..25ca231e58d 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -259,6 +259,21 @@ static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int
}
#endif
+/* don't call inside a loop */
+static int dm_tessface_to_poly_index(DerivedMesh *dm, int tessface_index)
+{
+ if (tessface_index != ORIGINDEX_NONE) {
+ /* double lookup */
+ const int *index_mf_to_mpoly;
+ if ((index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX))) {
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ return DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, tessface_index);
+ }
+ }
+
+ return ORIGINDEX_NONE;
+}
+
/* BMESH_TODO, return polygon index, not tessface */
static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start[3], float ray_end[3],
float r_location[3], float r_normal[3], int *index)
@@ -291,7 +306,7 @@ static void rna_Object_ray_cast(Object *ob, ReportList *reports, float ray_start
if (hit.dist <= dist) {
copy_v3_v3(r_location, hit.co);
copy_v3_v3(r_normal, hit.no);
- *index = hit.index;
+ *index = dm_tessface_to_poly_index(ob->derivedFinal, hit.index);
return;
}
}
@@ -330,7 +345,7 @@ static void rna_Object_closest_point_on_mesh(Object *ob, ReportList *reports, fl
if (BLI_bvhtree_find_nearest(treeData.tree, point_co, &nearest, treeData.nearest_callback, &treeData) != -1) {
copy_v3_v3(n_location, nearest.co);
copy_v3_v3(n_normal, nearest.no);
- *index = nearest.index;
+ *index = dm_tessface_to_poly_index(ob->derivedFinal, nearest.index);
return;
}
}