New feature; User definable Clipping Planes.
Press ALT+B in 3d window, draw a rect, and it becomes a clipping volume of 4 planes. You then can rotate the view anyway you like. Works for each 3d window individually. Disable it with another ALT+B press. Commit is huge because it had to change all selection code as well. The user-clipping planes are in 'eye space', the other clipping happens in projected 'viewport space'. Nice to notice is that the 'x=3200' convention (to denote a coordinate is clipped) now is a define. Define value is still a number though... but we now can get up to screens of 12000 pixels without issues! Known issue; here it refuses to draw the 'object centers' or Lamp icons within the clipping region. Can't find any reason for it... however, we might move to non-pixmaps for it anyway. Testing might reveil numerous issues, will be standby for it. Curious? Check this http://www.blender.org/bf/rt4.jpg
This commit is contained in:
@@ -826,7 +826,7 @@ void mouse_cursor(void)
|
||||
|
||||
initgrabz(fp[0], fp[1], fp[2]);
|
||||
|
||||
if(mval[0]!=3200) {
|
||||
if(mval[0]!=IS_CLIPPED) {
|
||||
|
||||
window_to_3d(dvec, mval[0]-mx, mval[1]-my);
|
||||
VecSubf(fp, fp, dvec);
|
||||
@@ -2001,3 +2001,59 @@ void fly(void)
|
||||
|
||||
}
|
||||
|
||||
void view3d_edit_clipping(View3D *v3d)
|
||||
{
|
||||
|
||||
if(v3d->flag & V3D_CLIPPING) {
|
||||
v3d->flag &= ~V3D_CLIPPING;
|
||||
scrarea_queue_winredraw(curarea);
|
||||
if(v3d->clipbb) MEM_freeN(v3d->clipbb);
|
||||
v3d->clipbb= NULL;
|
||||
}
|
||||
else {
|
||||
rcti rect;
|
||||
double mvmatrix[16];
|
||||
double projmatrix[16];
|
||||
double xs, ys, p[3];
|
||||
GLint viewport[4];
|
||||
short val;
|
||||
|
||||
/* get border in window coords */
|
||||
setlinestyle(2);
|
||||
val= get_border(&rect, 3);
|
||||
setlinestyle(0);
|
||||
if(val==0) return;
|
||||
|
||||
v3d->flag |= V3D_CLIPPING;
|
||||
v3d->clipbb= MEM_mallocN(sizeof(BoundBox), "clipbb");
|
||||
|
||||
/* convert border to 3d coordinates */
|
||||
|
||||
/* Get the matrices needed for gluUnProject */
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);
|
||||
|
||||
/* Set up viewport so that gluUnProject will give correct values */
|
||||
viewport[0] = 0;
|
||||
viewport[1] = 0;
|
||||
|
||||
/* four clipping planes and bounding volume */
|
||||
for(val=0; val<4; val++) {
|
||||
|
||||
xs= (val==0||val==3)?rect.xmin:rect.xmax;
|
||||
ys= (val==0||val==1)?rect.ymin:rect.ymax;
|
||||
gluUnProject(xs, ys, 0.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
|
||||
VECCOPY(v3d->clipbb->vec[val], p);
|
||||
|
||||
VECCOPY(v3d->clip[val], G.vd->viewinv[val & 1]);
|
||||
if(val>1) VecMulf(v3d->clip[val], -1.0f);
|
||||
v3d->clip[val][3]= - v3d->clip[val][0]*p[0] - v3d->clip[val][1]*p[1] - v3d->clip[val][2]*p[2];
|
||||
|
||||
gluUnProject(xs, ys, 1.0, mvmatrix, projmatrix, viewport, &p[0], &p[1], &p[2]);
|
||||
VECCOPY(v3d->clipbb->vec[4+val], p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user