forked from bartvdbraak/blender
View3D: avoid matrix multiply using ED_view3d_boundbox_clip
This commit is contained in:
parent
d4b8f6798d
commit
aee30184f3
@ -3698,7 +3698,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
|
/* ob->bb was set by derived mesh system, do NULL check just to be sure */
|
||||||
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) {
|
if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->bb))) {
|
||||||
const bool glsl = draw_glsl_material(scene, ob, v3d, dt);
|
const bool glsl = draw_glsl_material(scene, ob, v3d, dt);
|
||||||
const bool check_alpha = check_alpha_pass(base);
|
const bool check_alpha = check_alpha_pass(base);
|
||||||
|
|
||||||
@ -6421,7 +6421,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
|
|||||||
has_faces = BKE_displist_has_faces(&ob->curve_cache->disp);
|
has_faces = BKE_displist_has_faces(&ob->curve_cache->disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
|
if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
||||||
draw_index_wire = false;
|
draw_index_wire = false;
|
||||||
if (dm) {
|
if (dm) {
|
||||||
draw_mesh_object_outline(v3d, ob, dm);
|
draw_mesh_object_outline(v3d, ob, dm);
|
||||||
@ -6462,7 +6462,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign
|
|||||||
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
|
glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */
|
||||||
|
|
||||||
if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
|
if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) {
|
||||||
if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
|
if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
||||||
if (ob->type == OB_CURVE)
|
if (ob->type == OB_CURVE)
|
||||||
draw_index_wire = false;
|
draw_index_wire = false;
|
||||||
|
|
||||||
@ -6981,7 +6981,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
|
|||||||
draw_bounding_volume(ob, ob->boundtype);
|
draw_bounding_volume(ob, ob->boundtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
|
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
||||||
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7002,7 +7002,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
|
|||||||
draw_bounding_volume(ob, ob->boundtype);
|
draw_bounding_volume(ob, ob->boundtype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb)) {
|
else if (ED_view3d_boundbox_clip(rv3d, ob->bb)) {
|
||||||
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
empty_object = drawDispList(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
|
||||||
|
|
||||||
//XXX old animsys if (cu->path)
|
//XXX old animsys if (cu->path)
|
||||||
|
@ -2065,10 +2065,11 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (use_displist) {
|
if (use_displist) {
|
||||||
glMultMatrixf(dob->mat);
|
if (ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) {
|
||||||
if (ED_view3d_boundbox_clip(rv3d, dob->mat, &bb))
|
glMultMatrixf(dob->mat);
|
||||||
glCallList(displist);
|
glCallList(displist);
|
||||||
glLoadMatrixf(rv3d->viewmat);
|
glLoadMatrixf(rv3d->viewmat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
|
draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR);
|
||||||
|
@ -199,7 +199,8 @@ void VIEW3D_OT_localview(struct wmOperatorType *ot);
|
|||||||
void VIEW3D_OT_game_start(struct wmOperatorType *ot);
|
void VIEW3D_OT_game_start(struct wmOperatorType *ot);
|
||||||
|
|
||||||
|
|
||||||
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], const struct BoundBox *bb);
|
bool ED_view3d_boundbox_clip_ex(RegionView3D *rv3d, const struct BoundBox *bb, float obmat[4][4]);
|
||||||
|
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
|
||||||
|
|
||||||
void ED_view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *,
|
void ED_view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *,
|
||||||
float *ofs, float *quat, float *dist, float *lens,
|
float *ofs, float *quat, float *dist, float *lens,
|
||||||
|
@ -642,24 +642,15 @@ void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool view3d_boundbox_clip_m4(const BoundBox *bb, float persmatob[4][4])
|
||||||
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], const BoundBox *bb)
|
|
||||||
{
|
{
|
||||||
/* return 1: draw */
|
|
||||||
|
|
||||||
float mat[4][4];
|
|
||||||
float vec[4], min, max;
|
|
||||||
int a, flag = -1, fl;
|
int a, flag = -1, fl;
|
||||||
|
|
||||||
if (bb == NULL) return true;
|
|
||||||
if (bb->flag & BOUNDBOX_DISABLED) return true;
|
|
||||||
|
|
||||||
mul_m4_m4m4(mat, rv3d->persmat, obmat);
|
|
||||||
|
|
||||||
for (a = 0; a < 8; a++) {
|
for (a = 0; a < 8; a++) {
|
||||||
|
float vec[4], min, max;
|
||||||
copy_v3_v3(vec, bb->vec[a]);
|
copy_v3_v3(vec, bb->vec[a]);
|
||||||
vec[3] = 1.0;
|
vec[3] = 1.0;
|
||||||
mul_m4_v4(mat, vec);
|
mul_m4_v4(persmatob, vec);
|
||||||
max = vec[3];
|
max = vec[3];
|
||||||
min = -vec[3];
|
min = -vec[3];
|
||||||
|
|
||||||
@ -678,6 +669,28 @@ bool ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], const BoundB
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ED_view3d_boundbox_clip_ex(RegionView3D *rv3d, const BoundBox *bb, float obmat[4][4])
|
||||||
|
{
|
||||||
|
/* return 1: draw */
|
||||||
|
|
||||||
|
float persmatob[4][4];
|
||||||
|
|
||||||
|
if (bb == NULL) return true;
|
||||||
|
if (bb->flag & BOUNDBOX_DISABLED) return true;
|
||||||
|
|
||||||
|
mul_m4_m4m4(persmatob, rv3d->persmat, obmat);
|
||||||
|
|
||||||
|
return view3d_boundbox_clip_m4(bb, persmatob);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const BoundBox *bb)
|
||||||
|
{
|
||||||
|
if (bb == NULL) return true;
|
||||||
|
if (bb->flag & BOUNDBOX_DISABLED) return true;
|
||||||
|
|
||||||
|
return view3d_boundbox_clip_m4(bb, rv3d->persmatob);
|
||||||
|
}
|
||||||
|
|
||||||
float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y)
|
float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y)
|
||||||
{
|
{
|
||||||
ViewDepths *vd = vc->rv3d->depths;
|
ViewDepths *vd = vc->rv3d->depths;
|
||||||
|
Loading…
Reference in New Issue
Block a user