diff options
-rw-r--r-- | source/blender/blenlib/BLI_math_base.h | 14 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_select.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 15 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_iterators.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_project.c | 3 |
8 files changed, 64 insertions, 8 deletions
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 04cf0b9d275..4b71babdba1 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -245,9 +245,19 @@ double double_round(double x, int ndigits); BLI_assert((fabsf(_test_unit - 1.0f) < BLI_ASSERT_UNIT_EPSILON) || \ (fabsf(_test_unit) < BLI_ASSERT_UNIT_EPSILON)); \ } (void)0 + +# define BLI_ASSERT_ZERO_M3(m) { \ + BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 9) != 0.0); \ +} (void)0 + +# define BLI_ASSERT_ZERO_M4(m) { \ + BLI_assert(dot_vn_vn((const float *)m, (const float *)m, 16) != 0.0); \ +} (void)0 #else -# define BLI_ASSERT_UNIT_V2(v) (void)0 -# define BLI_ASSERT_UNIT_V3(v) (void)0 +# define BLI_ASSERT_UNIT_V2(v) (void)(v) +# define BLI_ASSERT_UNIT_V3(v) (void)(v) +# define BLI_ASSERT_ZERO_M3(m) (void)(m) +# define BLI_ASSERT_ZERO_M4(m) (void)(m) #endif #endif /* __BLI_MATH_BASE_H__ */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index b111295fa26..d6d82696422 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -276,7 +276,13 @@ int ED_operator_rv3d_user_region_poll(struct bContext *C); void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d); void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d); - +#ifdef DEBUG +void ED_view3d_clear_mats_rv3d(struct RegionView3D *rv3d); +void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d); +#else +# define ED_view3d_clear_mats_rv3d(rv3d) (void)(rv3d) +# define ED_view3d_check_mats_rv3d(rv3d) (void)(rv3d) +#endif int ED_view3d_scene_layer_set(int lay, const int *values, int *active); bool ED_view3d_context_activate(struct bContext *C); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 80ef8894971..8eee6bcf6da 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -587,6 +587,8 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) data.dist = FLT_MAX; data.toFace = efa; + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); + mesh_foreachScreenFace(vc, findnearestface__getDistance, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if ((vc->em->selectmode == SCE_SELECT_FACE) || (data.dist < *r_dist)) { /* only faces, no dist check */ @@ -613,14 +615,13 @@ BMFace *EDBM_face_find_nearest(ViewContext *vc, float *r_dist) data.dist = *r_dist; data.closest = NULL; data.closestIndex = 0; - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); data.pass = 0; + ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if (data.dist > 3.0f) { data.pass = 1; - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); mesh_foreachScreenFace(vc, findnearestface__doClosest, &data, V3D_PROJ_TEST_CLIP_DEFAULT); } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 2ff52b51069..5af2296e60a 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2097,7 +2097,9 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) /* being set in code below */ arm->layer_used = 0; - + + ED_view3d_check_mats_rv3d(rv3d); + /* envelope (deform distance) */ if (arm->drawtype == ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index d1cae903bec..09a2384e868 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -7001,6 +7001,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if ((base->flag & OB_FROMDUPLI) || (v3d->flag2 & V3D_RENDER_OVERRIDE)) { + ED_view3d_clear_mats_rv3d(rv3d); return; } @@ -7144,6 +7145,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } free_old_images(); + + ED_view3d_clear_mats_rv3d(rv3d); } /* ***************** BACKBUF SEL (BBS) ********* */ diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 45274cbd619..363eea480b9 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -243,6 +243,21 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d) glMultMatrixf(ob->obmat); } +#ifdef DEBUG +/* ensure we correctly initialize */ +void ED_view3d_clear_mats_rv3d(struct RegionView3D *rv3d) +{ + zero_m4(rv3d->viewmatob); + zero_m4(rv3d->persmatob); +} + +void ED_view3d_check_mats_rv3d(struct RegionView3D *rv3d) +{ + BLI_ASSERT_ZERO_M4(rv3d->viewmatob); + BLI_ASSERT_ZERO_M4(rv3d->persmatob); +} +#endif + /* ******************** default callbacks for view3d space ***************** */ static SpaceLink *view3d_new(const bContext *C) diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c index 81e890c37ee..9e310c84bd0 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.c +++ b/source/blender/editors/space_view3d/view3d_iterators.c @@ -112,6 +112,8 @@ void meshobject_foreachScreenVert( foreachScreenObjectVert_userData data; DerivedMesh *dm = mesh_get_derived_deform(vc->scene, vc->obact, CD_MASK_BAREMESH); + ED_view3d_check_mats_rv3d(vc->rv3d); + data.vc = *vc; data.func = func; data.userData = userData; @@ -151,6 +153,8 @@ void mesh_foreachScreenVert( foreachScreenVert_userData data; DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH); + ED_view3d_check_mats_rv3d(vc->rv3d); + data.vc = *vc; data.func = func; data.userData = userData; @@ -203,6 +207,8 @@ void mesh_foreachScreenEdge( foreachScreenEdge_userData data; DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH); + ED_view3d_check_mats_rv3d(vc->rv3d); + data.vc = *vc; data.win_rect.xmin = 0; @@ -247,13 +253,13 @@ void mesh_foreachScreenFace( foreachScreenFace_userData data; DerivedMesh *dm = editbmesh_get_derived_cage(vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH); + ED_view3d_check_mats_rv3d(vc->rv3d); + data.vc = *vc; data.func = func; data.userData = userData; data.clip_flag = clip_flag; - ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - EDBM_index_arrays_ensure(vc->em, BM_FACE); dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data); @@ -272,6 +278,8 @@ void nurbs_foreachScreenVert( int i; ListBase *nurbs = BKE_curve_editNurbs_get(cu); + ED_view3d_check_mats_rv3d(vc->rv3d); + if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ } @@ -339,6 +347,8 @@ void mball_foreachScreenElem( MetaBall *mb = (MetaBall *)vc->obedit->data; MetaElem *ml; + ED_view3d_check_mats_rv3d(vc->rv3d); + for (ml = mb->editelems->first; ml; ml = ml->next) { float screen_co[2]; if (ED_view3d_project_float_object(vc->ar, &ml->x, screen_co, clip_flag) == V3D_PROJ_RET_OK) { @@ -361,6 +371,8 @@ void lattice_foreachScreenVert( float *co = dl ? dl->verts : NULL; int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; + ED_view3d_check_mats_rv3d(vc->rv3d); + if (clip_flag & V3D_PROJ_TEST_CLIP_BB) { ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */ } @@ -386,6 +398,8 @@ void armature_foreachScreenBone( bArmature *arm = vc->obedit->data; EditBone *ebone; + ED_view3d_check_mats_rv3d(vc->rv3d); + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { float screen_co_a[2], screen_co_b[2]; @@ -429,6 +443,8 @@ void pose_foreachScreenBone( bPose *pose = vc->obact->pose; bPoseChannel *pchan; + ED_view3d_check_mats_rv3d(vc->rv3d); + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (PBONE_VISIBLE(arm, pchan->bone)) { float screen_co_a[2], screen_co_b[2]; diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 4be4328d6c3..b9d24b248da 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -237,6 +237,7 @@ eV3DProjStatus ED_view3d_project_short_global(const ARegion *ar, const float co[ eV3DProjStatus ED_view3d_project_short_object(const ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; + ED_view3d_check_mats_rv3d(rv3d); return ED_view3d_project_short_ex(ar, rv3d->persmatob, true, co, r_co, flag); } @@ -250,6 +251,7 @@ eV3DProjStatus ED_view3d_project_int_global(const ARegion *ar, const float co[3] eV3DProjStatus ED_view3d_project_int_object(const ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; + ED_view3d_check_mats_rv3d(rv3d); return ED_view3d_project_int_ex(ar, rv3d->persmatob, true, co, r_co, flag); } @@ -263,6 +265,7 @@ eV3DProjStatus ED_view3d_project_float_global(const ARegion *ar, const float co[ eV3DProjStatus ED_view3d_project_float_object(const ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; + ED_view3d_check_mats_rv3d(rv3d); return ED_view3d_project_float_ex(ar, rv3d->persmatob, true, co, r_co, flag); } |