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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-12-02 10:46:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-02 10:46:14 +0300
commite16d39b793ea0a1584e9041b35a02d97e056e849 (patch)
tree783e73c568a16c77e59ae54f46395d234d37fd68 /source
parenta5c0964c70cc4c12e574ef7e51fcf6c0b5f38680 (diff)
Transform Snap: add optional face index arg
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/ED_transform.h2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c4
-rw-r--r--source/blender/editors/transform/transform_snap.c40
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c2
-rw-r--r--source/blenderplayer/bad_level_call_stubs/stubs.c2
6 files changed, 31 insertions, 21 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 874c6934f6d..19bfb94e130 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -205,7 +205,7 @@ bool snapObjectsRayEx(
const float mval[2], SnapSelect snap_select, short snap_mode,
const float ray_start[3], const float ray_normal[3], float *ray_depth,
/* return args */
- float r_loc[3], float r_no[3], float *r_dist_px,
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index,
struct Object **r_ob, float r_obmat[4][4]);
bool snapNodesTransform(
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 498aa3a5230..b09cbedb6fa 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -5171,7 +5171,7 @@ bool ED_view3d_snap_from_ray(
scene, NULL, NULL, NULL, obedit,
NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
ray_start, ray_normal, &ray_dist,
- r_co, r_no_dummy, NULL,
+ r_co, r_no_dummy, NULL, NULL,
NULL, NULL);
return ret;
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index b71b6b86356..8b3ea2a1fee 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -421,7 +421,7 @@ static bool walk_floor_distance_get(bContext *C, RegionView3D *rv3d, WalkInfo *w
CTX_data_scene(C), NULL, NULL, NULL, NULL,
NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
ray_start, ray_normal, r_distance,
- r_location, r_normal, NULL,
+ r_location, r_normal, NULL, NULL,
NULL, NULL);
/* artifically scale the distance to the scene size */
@@ -455,7 +455,7 @@ static bool walk_ray_cast(bContext *C, RegionView3D *rv3d, WalkInfo *walk, float
CTX_data_scene(C), NULL, NULL, NULL, NULL,
NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
ray_start, ray_normal, ray_distance,
- r_location, r_normal, NULL,
+ r_location, r_normal, NULL, NULL,
NULL, NULL);
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index bdf85b089a4..359e191c90d 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -1523,11 +1523,17 @@ static bool snapCurve(
return retval;
}
+static int dm_looptri_to_poly_index(DerivedMesh *dm, const MLoopTri *lt)
+{
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ return index_mp_to_orig ? index_mp_to_orig[lt->poly] : lt->poly;
+}
+
static bool snapDerivedMesh(
ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
const float mval[2], const short snap_to, bool do_bb,
const float ray_start[3], const float ray_normal[3], const float ray_origin[3], float *ray_depth,
- float r_loc[3], float r_no[3], float *r_dist_px)
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index)
{
bool retval = false;
const bool do_ray_start_correction = (
@@ -1653,6 +1659,10 @@ static bool snapDerivedMesh(
normalize_v3(r_no);
retval = true;
+
+ if (r_index) {
+ *r_index = dm_looptri_to_poly_index(dm, &treeData.looptri[hit.index]);
+ }
}
}
free_bvhtree_from_mesh(&treeData);
@@ -1897,7 +1907,7 @@ static bool snapObject(
const float mval[2], const short snap_to,
const float ray_start[3], const float ray_normal[3], const float ray_origin[3], float *ray_depth,
/* return args */
- float r_loc[3], float r_no[3], float *r_dist_px,
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index,
Object **r_ob, float r_obmat[4][4])
{
bool retval = false;
@@ -1928,7 +1938,7 @@ static bool snapObject(
retval = snapDerivedMesh(
ar, ob, dm, em, obmat, mval, snap_to, do_bb,
ray_start, ray_normal, ray_origin, ray_depth,
- r_loc, r_no, r_dist_px);
+ r_loc, r_no, r_dist_px, r_index);
dm->release(dm);
}
@@ -1972,7 +1982,7 @@ static bool snapObjectsRay(
const float mval[2], SnapSelect snap_select, const short snap_to,
const float ray_start[3], const float ray_normal[3], const float ray_origin[3], float *ray_depth,
/* return args */
- float r_loc[3], float r_no[3], float *r_dist_px,
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index,
Object **r_ob, float r_obmat[4][4])
{
Base *base;
@@ -1985,7 +1995,7 @@ static bool snapObjectsRay(
scene, ar, ob, ob->obmat, true,
mval, snap_to,
ray_start, ray_normal, ray_origin, ray_depth,
- r_loc, r_no, r_dist_px, r_ob, r_obmat);
+ r_loc, r_no, r_dist_px, r_index, r_ob, r_obmat);
}
/* Need an exception for particle edit because the base is flagged with BA_HAS_RECALC_DATA
@@ -2000,7 +2010,7 @@ static bool snapObjectsRay(
scene, ar, ob, ob->obmat, false,
mval, snap_to,
ray_start, ray_normal, ray_origin, ray_depth,
- r_loc, r_no, r_dist_px, r_ob, r_obmat);
+ r_loc, r_no, r_dist_px, r_index, r_ob, r_obmat);
}
for (base = FIRSTBASE; base != NULL; base = base->next) {
@@ -2032,7 +2042,7 @@ static bool snapObjectsRay(
scene, ar, dupli_snap, dupli_ob->mat, use_obedit_dupli,
mval, snap_to,
ray_start, ray_normal, ray_origin, ray_depth,
- r_loc, r_no, r_dist_px, r_ob, r_obmat);
+ r_loc, r_no, r_dist_px, r_index, r_ob, r_obmat);
}
free_object_duplilist(lb);
@@ -2042,7 +2052,7 @@ static bool snapObjectsRay(
scene, ar, ob_snap, ob->obmat, use_obedit,
mval, snap_to,
ray_start, ray_normal, ray_origin, ray_depth,
- r_loc, r_no, r_dist_px, r_ob, r_obmat);
+ r_loc, r_no, r_dist_px, r_index, r_ob, r_obmat);
}
}
@@ -2052,7 +2062,7 @@ static bool snapObjects(
Scene *scene, View3D *v3d, ARegion *ar, Base *base_act, Object *obedit,
const float mval[2], SnapSelect snap_select, const short snap_to,
float *ray_depth,
- float r_loc[3], float r_no[3], float *r_dist_px)
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index)
{
float ray_start[3], ray_normal[3], ray_orgigin[3];
@@ -2064,7 +2074,7 @@ static bool snapObjects(
scene, v3d, ar, base_act, obedit,
mval, snap_select, snap_to,
ray_start, ray_normal, ray_orgigin, ray_depth,
- r_loc, r_no, r_dist_px, NULL, NULL);
+ r_loc, r_no, r_dist_px, r_index, NULL, NULL);
}
bool snapObjectsTransform(
@@ -2087,7 +2097,7 @@ bool snapObjectsTransform(
t->scene, t->view, t->ar, base_act, obedit,
mval, snap_select, t->scene->toolsettings->snap_mode,
&ray_dist,
- r_loc, r_no, r_dist_px);
+ r_loc, r_no, r_dist_px, NULL);
}
bool snapObjectsContext(
@@ -2105,7 +2115,7 @@ bool snapObjectsContext(
scene, v3d, ar, scene->basact, obedit,
mval, snap_select, scene->toolsettings->snap_mode,
&ray_dist,
- r_loc, r_no, r_dist_px);
+ r_loc, r_no, r_dist_px, NULL);
}
bool snapObjectsEx(
@@ -2118,20 +2128,20 @@ bool snapObjectsEx(
scene, v3d, ar, base_act, obedit,
mval, snap_select, snap_to,
ray_depth,
- r_loc, r_no, r_dist_px);
+ r_loc, r_no, r_dist_px, NULL);
}
bool snapObjectsRayEx(
Scene *scene, View3D *v3d, ARegion *ar, Base *base_act, Object *obedit,
const float mval[2], SnapSelect snap_select, const short snap_to,
const float ray_start[3], const float ray_normal[3], float *ray_depth,
- float r_loc[3], float r_no[3], float *r_dist_px,
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index,
Object **r_ob, float r_obmat[4][4])
{
return snapObjectsRay(
scene, v3d, ar, base_act, obedit,
mval, snap_select, snap_to,
ray_start, ray_normal, ray_start, ray_depth,
- r_loc, r_no, r_dist_px,
+ r_loc, r_no, r_dist_px, r_index,
r_ob, r_obmat);
}
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 6c5a29c02cd..cc56f5e477d 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -151,7 +151,7 @@ static void rna_Scene_ray_cast(Scene *scene, float ray_start[3], float ray_end[3
scene, NULL, NULL, NULL, NULL,
NULL, SNAP_ALL, SCE_SNAP_MODE_FACE,
ray_start, ray_nor, &ray_dist,
- r_location, r_normal, NULL,
+ r_location, r_normal, NULL, NULL,
r_ob, (float(*)[4])r_obmat))
{
*r_success = true;
diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 07c48c00877..c277a0436dd 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -516,7 +516,7 @@ bool snapObjectsRayEx(
struct Scene *scene, struct View3D *v3d, struct ARegion *ar, struct Base *base_act, struct Object *obedit,
const float mval[2], SnapSelect snap_select, short snap_mode,
const float ray_start[3], const float ray_normal[3], float *ray_dist,
- float r_loc[3], float r_no[3], float *r_dist_px,
+ float r_loc[3], float r_no[3], float *r_dist_px, int *r_index,
struct Object **r_ob, float r_obmat[4][4]) RET_ZERO
void ED_lattice_editlatt_make(struct Object *obedit) RET_NONE