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:
authorAntony Riakiotakis <kalast@gmail.com>2014-06-18 19:40:11 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-06-18 19:40:11 +0400
commit47ec0394ca3d03e07c07a67e8f8d1625aedd39dd (patch)
tree2c2c505bd67d4fb2c26ec9ec440d414ee158dac2
parentd9de1b367e8e6d48556c2cd1621c27275ef07aa9 (diff)
Fix T40679.
Cleanest way here is not do bounding box collision for editmeshes at all. Decision is taken because: * Usually we want to do the snapping to the edited mesh anyway (when we don't the mesh is skipped completely, so we don't need to worry for extra checks) * Bounding box is calculated from derived mesh. This means that for subsurfed meshes for instance, the bounding box may be significantly smaller than the size of the edit mesh.
-rw-r--r--source/blender/editors/transform/transform_snap.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index b116721868e..451837fd311 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -507,7 +507,6 @@ static void initSnappingMode(TransInfo *t)
if (t->tsnap.applySnap != NULL && // A snapping function actually exist
(obedit != NULL && ELEM5(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE, OB_MBALL)) ) // Temporary limited to edit mode meshes, armature, curves, mballs
{
- BoundBox *bb_init;
/* Exclude editmesh if using proportional edit */
if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) {
t->tsnap.modeSelect = SNAP_NOT_OBEDIT;
@@ -1490,13 +1489,12 @@ static bool snapCurve(short snap_mode, ARegion *ar, Object *ob, Curve *cu, float
static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
const float ray_start[3], const float ray_normal[3], const float ray_origin[3],
- const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth)
+ const float mval[2], float r_loc[3], float r_no[3], float *r_dist_px, float *r_depth, bool do_bb)
{
bool retval = false;
int totvert = dm->getNumVerts(dm);
if (totvert > 0) {
- BoundBox *bb;
float imat[4][4];
float timat[3][3]; /* transpose inverse matrix for normals */
float ray_start_local[3], ray_normal_local[3], local_scale, len_diff = TRANSFORM_DIST_MAX_RAY;
@@ -1514,9 +1512,11 @@ static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMes
/* local scale in normal direction */
local_scale = normalize_v3(ray_normal_local);
- bb = BKE_object_boundbox_get(ob);
- if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) {
- return retval;
+ if (do_bb) {
+ BoundBox *bb = BKE_object_boundbox_get(ob);
+ if (!BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local, &len_diff)) {
+ return retval;
+ }
}
switch (snap_mode) {
@@ -1814,17 +1814,19 @@ static bool snapObject(Scene *scene, short snap_mode, ARegion *ar, Object *ob, f
if (ob->type == OB_MESH) {
BMEditMesh *em;
DerivedMesh *dm;
+ bool do_bb = true;
if (use_obedit) {
em = BKE_editmesh_from_object(ob);
dm = editbmesh_get_derived_cage(scene, ob, em, CD_MASK_BAREMESH);
+ do_bb = false;
}
else {
em = NULL;
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
}
- retval = snapDerivedMesh(snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_depth);
+ retval = snapDerivedMesh(snap_mode, ar, ob, dm, em, obmat, ray_start, ray_normal, ray_origin, mval, r_loc, r_no, r_dist_px, r_depth, do_bb);
dm->release(dm);
}