637 |
* parents' unit squares do not intersect. |
* parents' unit squares do not intersect. |
638 |
*/ |
*/ |
639 |
class CullingCoordSys : public CoordSys { |
class CullingCoordSys : public CoordSys { |
640 |
|
CoordSys *testSuper; |
641 |
CoordSys *clipSuper; |
CoordSys *clipSuper; |
642 |
|
protected: |
643 |
/** Checks if two parallel rectangle intersects. |
/** Checks if two parallel rectangle intersects. |
644 |
* "Two rectangles, represented by lower left and upper right points (p1, p2) |
* "Two rectangles, represented by lower left and upper right points (p1, p2) |
645 |
* and (p3, p4), intersects if and only if the conjunction |
* and (p3, p4), intersects if and only if the conjunction |
655 |
DBG(dbg_cull) << "called CullingCoordsys::parallellRectIntersect\n"; |
DBG(dbg_cull) << "called CullingCoordsys::parallellRectIntersect\n"; |
656 |
DBG(dbg_cull) << "(" << p1.x << "," << p1.y << "), (" << p2.x << "," << p2.y << ") <=> (" |
DBG(dbg_cull) << "(" << p1.x << "," << p1.y << "), (" << p2.x << "," << p2.y << ") <=> (" |
657 |
<< p3.x << "," << p3.y << "), (" << p4.x << "," << p4.y << ")\n"; |
<< p3.x << "," << p3.y << "), (" << p4.x << "," << p4.y << ")\n"; |
658 |
|
|
659 |
|
|
660 |
|
glLineWidth(1); |
661 |
|
glColor3f(1, 1, 1); |
662 |
|
glDisable(GL_TEXTURE_2D); |
663 |
|
glBegin(GL_LINE_LOOP); |
664 |
|
glVertex3f(p1.x, p1.y,0); |
665 |
|
glVertex3f(p1.x, p2.y,0); |
666 |
|
glVertex3f(p2.x, p2.y,0); |
667 |
|
glVertex3f(p2.x, p1.y,0); |
668 |
|
glEnd(); |
669 |
|
glColor3f(1, 0 , 1); |
670 |
|
glBegin(GL_LINE_LOOP); |
671 |
|
glVertex3f(p3.x, p3.y,0); |
672 |
|
glVertex3f(p3.x, p4.y,0); |
673 |
|
glVertex3f(p4.x, p4.y,0); |
674 |
|
glVertex3f(p4.x, p3.y,0); |
675 |
|
glEnd(); |
676 |
|
|
677 |
|
|
678 |
return (p2.x > p3.x) && (p4.x > p1.x) && (p2.y > p3.y) && (p4.y > p1.y); |
return (p2.x > p3.x) && (p4.x > p1.x) && (p2.y > p3.y) && (p4.y > p1.y); |
679 |
} |
} |
722 |
int check_dist; |
int check_dist; |
723 |
|
|
724 |
/** Initializing. */ |
/** Initializing. */ |
725 |
check_dist = 30; // XXX |
check_dist = 100; // XXX Adjusts the scanning frequency. |
726 |
|
|
727 |
ZPt o = cs->transform(ZPt(0, 0, 0)); |
ZPt o = cs->transform(ZPt(0, 0, 0)); |
728 |
ZPt u = cs->transform(ZPt(1, 1, 0)); |
ZPt u = cs->transform(ZPt(1, 1, 0)); |
778 |
} |
} |
779 |
public: |
public: |
780 |
CullingCoordSys() : clipSuper(0) { } |
CullingCoordSys() : clipSuper(0) { } |
781 |
CullingCoordSys(CoordSys *parent, CoordSys *clip) |
CullingCoordSys(CoordSys *parent, CoordSys *test, CoordSys *clip) |
782 |
: CoordSys(parent), clipSuper(clip) { } |
: CoordSys(parent), testSuper(test), clipSuper(clip) { } |
783 |
virtual void setSuper(CoordSys **super) { |
virtual void setSuper(CoordSys **super) { |
784 |
DBG(dbg_cull) << "called CullingCoordsys::setSuper\n"; |
DBG(dbg_cull) << "called CullingCoordsys::setSuper\n"; |
785 |
CoordSys::setSuper(super); |
CoordSys::setSuper(super); |
786 |
this->clipSuper = super[1]; |
this->testSuper = super[1]; |
787 |
|
this->clipSuper = super[2]; |
788 |
} |
} |
789 |
enum { NParams = 0, NPrevious = 2, NParents = 2 }; |
enum { NParams = 0, NPrevious = 3, NParents = 3 }; |
790 |
virtual void setParams(float *params) { } |
virtual void setParams(float *params) { } |
791 |
virtual CoordSys *createInverse() { |
virtual CoordSys *createInverse() { |
792 |
DBG(dbg_cull) << "called CullingCoordsys::createInverse\n"; |
DBG(dbg_cull) << "called CullingCoordsys::createInverse\n"; |
824 |
*/ |
*/ |
825 |
ZPt p1, p2, p3, p4; |
ZPt p1, p2, p3, p4; |
826 |
|
|
827 |
if (super->nonlinearity(ZPt(0.5, 0.5, 0), 1/sqrt(2)) != 0) |
if (testSuper->nonlinearity(ZPt(0.5, 0.5, 0), 1/sqrt(2)) != 0) |
828 |
findDistortedBoundingBox(super, p1, p2); |
findDistortedBoundingBox(testSuper, p1, p2); |
829 |
else findBoundingBox(super, p1, p2); |
else findBoundingBox(testSuper, p1, p2); |
830 |
|
|
831 |
if (clipSuper->nonlinearity(ZPt(0.5, 0.5, 0), 1/sqrt(2)) != 0) |
if (clipSuper->nonlinearity(ZPt(0.5, 0.5, 0), 1/sqrt(2)) != 0) |
832 |
findDistortedBoundingBox(clipSuper, p3, p4); |
findDistortedBoundingBox(clipSuper, p3, p4); |
962 |
|
|
963 |
|
|
964 |
if(csind2 <= 0) { |
if(csind2 <= 0) { |
965 |
|
|
966 |
if(show1) { |
if(show1) { |
967 |
for(int j = 0; j<npars; j++) { |
for(int j = 0; j<npars; j++) { |
968 |
params.push_back(points1[ind1 + j]); |
params.push_back(points1[ind1 + j]); |
1061 |
cs[i] = c; |
cs[i] = c; |
1062 |
c->setSuper(prev); |
c->setSuper(prev); |
1063 |
c->setParams(&(params[0]) + parind); |
c->setParams(&(params[0]) + parind); |
1064 |
|
|
1065 |
if (!cs[i]->shouldBeDrawn()) { |
if (!cs[i]->shouldBeDrawn()) { |
1066 |
DBG(dbg) << "CS should not be drawn... freeing it with delete.\n"; |
DBG(dbg) << "CS should not be drawn... freeing it with delete.\n"; |
1067 |
delete cs[i]; // Must be deleted, because created with "new" in factories. |
delete cs[i]; // Must be deleted, because created with "new" in factories. |
1068 |
cs[i] = NULL; |
cs[i] = NULL; |
1069 |
} |
} |
1070 |
} |
} |
1071 |
nextInd:; |
nextInd:; |
1072 |
} |
} |
1089 |
|
|
1090 |
} |
} |
1091 |
|
|
1092 |
|
|