Added a bunch of files synched with 0.8.42
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "osgUtil/IntersectVisitor"
|
||||
#include "osg/DCS"
|
||||
#include "osg/Transform"
|
||||
#include "osg/Geode"
|
||||
#include "osg/LOD"
|
||||
#include "osg/Billboard"
|
||||
@@ -24,13 +24,14 @@ IntersectState::IntersectState()
|
||||
_segmentMaskStack.push_back(0xffffffff);
|
||||
}
|
||||
|
||||
|
||||
IntersectState::~IntersectState()
|
||||
{
|
||||
if (_matrix) _matrix->unref();
|
||||
if (_inverse) _inverse->unref();
|
||||
for(SegList::iterator itr=_segList.begin();
|
||||
itr!=_segList.end();
|
||||
++itr)
|
||||
for(LineSegmentList::iterator itr=_segList.begin();
|
||||
itr!=_segList.end();
|
||||
++itr)
|
||||
{
|
||||
itr->first->unref();
|
||||
itr->second->unref();
|
||||
@@ -40,40 +41,42 @@ IntersectState::~IntersectState()
|
||||
_inverse = (osg::Matrix *)0xffffffff;
|
||||
}
|
||||
|
||||
bool IntersectState::isCulled(const BoundingSphere& bs,SegmentMask& segMaskOut)
|
||||
|
||||
bool IntersectState::isCulled(const BoundingSphere& bs,LineSegmentmentMask& segMaskOut)
|
||||
{
|
||||
bool hit = false;
|
||||
SegmentMask mask = 0x00000001;
|
||||
LineSegmentmentMask mask = 0x00000001;
|
||||
segMaskOut = 0x00000000;
|
||||
SegmentMask segMaskIn = _segmentMaskStack.back();
|
||||
// notify(INFO) << << "IntersectState::isCulled() mask in "<<segMaskIn<<" ";
|
||||
for(IntersectState::SegList::iterator sitr=_segList.begin();
|
||||
sitr!=_segList.end();
|
||||
++sitr)
|
||||
LineSegmentmentMask segMaskIn = _segmentMaskStack.back();
|
||||
// notify(INFO) << << "IntersectState::isCulled() mask in "<<segMaskIn<<" ";
|
||||
for(IntersectState::LineSegmentList::iterator sitr=_segList.begin();
|
||||
sitr!=_segList.end();
|
||||
++sitr)
|
||||
{
|
||||
if ((segMaskIn & mask) && (sitr->second)->intersect(bs))
|
||||
if ((segMaskIn & mask) && (sitr->second)->intersect(bs))
|
||||
{
|
||||
// notify(INFO) << << "Hit ";
|
||||
// notify(INFO) << << "Hit ";
|
||||
segMaskOut = segMaskOut| mask;
|
||||
hit = true;
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
// notify(INFO) << << "mask = "<<segMaskOut<<endl;
|
||||
// notify(INFO) << << "mask = "<<segMaskOut<<endl;
|
||||
return !hit;
|
||||
}
|
||||
|
||||
bool IntersectState::isCulled(const BoundingBox& bb,SegmentMask& segMaskOut)
|
||||
|
||||
bool IntersectState::isCulled(const BoundingBox& bb,LineSegmentmentMask& segMaskOut)
|
||||
{
|
||||
bool hit = false;
|
||||
SegmentMask mask = 0x00000001;
|
||||
LineSegmentmentMask mask = 0x00000001;
|
||||
segMaskOut = 0x00000000;
|
||||
SegmentMask segMaskIn = _segmentMaskStack.back();
|
||||
for(IntersectState::SegList::iterator sitr=_segList.begin();
|
||||
sitr!=_segList.end();
|
||||
++sitr)
|
||||
LineSegmentmentMask segMaskIn = _segmentMaskStack.back();
|
||||
for(IntersectState::LineSegmentList::iterator sitr=_segList.begin();
|
||||
sitr!=_segList.end();
|
||||
++sitr)
|
||||
{
|
||||
if ((segMaskIn & mask) && (sitr->second)->intersect(bb))
|
||||
if ((segMaskIn & mask) && (sitr->second)->intersect(bb))
|
||||
{
|
||||
segMaskOut = segMaskOut| mask;
|
||||
hit = true;
|
||||
@@ -83,21 +86,23 @@ bool IntersectState::isCulled(const BoundingBox& bb,SegmentMask& segMaskOut)
|
||||
return !hit;
|
||||
}
|
||||
|
||||
|
||||
Hit::Hit()
|
||||
{
|
||||
_originalSeg=NULL;
|
||||
_localSeg=NULL;
|
||||
_originalLineSegment=NULL;
|
||||
_localLineSegment=NULL;
|
||||
_geode=NULL;
|
||||
_geoset=NULL;
|
||||
_matrix=NULL;
|
||||
}
|
||||
|
||||
|
||||
Hit::Hit(const Hit& hit):Referenced()
|
||||
{
|
||||
// copy data across.
|
||||
_ratio = hit._ratio;
|
||||
_originalSeg = hit._originalSeg;
|
||||
_localSeg = hit._localSeg;
|
||||
_originalLineSegment = hit._originalLineSegment;
|
||||
_localLineSegment = hit._localLineSegment;
|
||||
_nodePath = hit._nodePath;
|
||||
_geode = hit._geode;
|
||||
_geoset = hit._geoset;
|
||||
@@ -109,22 +114,23 @@ Hit::Hit(const Hit& hit):Referenced()
|
||||
_intersectNormal = hit._intersectNormal;
|
||||
|
||||
if (_matrix) _matrix->ref();
|
||||
if (_originalSeg) _originalSeg->ref();
|
||||
if (_localSeg) _localSeg->ref();
|
||||
if (_originalLineSegment) _originalLineSegment->ref();
|
||||
if (_localLineSegment) _localLineSegment->ref();
|
||||
}
|
||||
|
||||
|
||||
Hit::~Hit()
|
||||
{
|
||||
if (_matrix) _matrix->unref();
|
||||
if (_originalSeg) _originalSeg->unref();
|
||||
if (_localSeg) _localSeg->unref();
|
||||
if (_originalLineSegment) _originalLineSegment->unref();
|
||||
if (_localLineSegment) _localLineSegment->unref();
|
||||
_matrix = (osg::Matrix*)0xffffffff;
|
||||
_localSeg = (osg::Seg*)0xffffffff;
|
||||
_localSeg = (osg::Seg*)0xffffffff;
|
||||
_localLineSegment = (osg::LineSegment*)0xffffffff;
|
||||
_localLineSegment = (osg::LineSegment*)0xffffffff;
|
||||
_geode = (osg::Geode*)0xffffffff;
|
||||
}
|
||||
|
||||
|
||||
Hit& Hit::operator = (const Hit& hit)
|
||||
{
|
||||
if (&hit==this) return *this;
|
||||
@@ -136,23 +142,23 @@ Hit& Hit::operator = (const Hit& hit)
|
||||
_matrix = hit._matrix;
|
||||
if (_matrix) _matrix->ref();
|
||||
}
|
||||
if (_originalSeg!=hit._originalSeg)
|
||||
if (_originalLineSegment!=hit._originalLineSegment)
|
||||
{
|
||||
if (_originalSeg) _originalSeg->unref();
|
||||
_originalSeg = hit._originalSeg;
|
||||
if (_originalSeg) _originalSeg->ref();
|
||||
if (_originalLineSegment) _originalLineSegment->unref();
|
||||
_originalLineSegment = hit._originalLineSegment;
|
||||
if (_originalLineSegment) _originalLineSegment->ref();
|
||||
}
|
||||
if (_localSeg!=hit._localSeg)
|
||||
if (_localLineSegment!=hit._localLineSegment)
|
||||
{
|
||||
if (_localSeg) _localSeg->unref();
|
||||
_localSeg = hit._localSeg;
|
||||
if (_localSeg) _localSeg->ref();
|
||||
if (_localLineSegment) _localLineSegment->unref();
|
||||
_localLineSegment = hit._localLineSegment;
|
||||
if (_localLineSegment) _localLineSegment->ref();
|
||||
}
|
||||
|
||||
// copy data across.
|
||||
_ratio = hit._ratio;
|
||||
_originalSeg = hit._originalSeg;
|
||||
_localSeg = hit._localSeg;
|
||||
_originalLineSegment = hit._originalLineSegment;
|
||||
_localLineSegment = hit._localLineSegment;
|
||||
_nodePath = hit._nodePath;
|
||||
_geode = hit._geode;
|
||||
_geoset = hit._geoset;
|
||||
@@ -165,78 +171,78 @@ Hit& Hit::operator = (const Hit& hit)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
IntersectVisitor::IntersectVisitor()
|
||||
{
|
||||
// overide the default node visitor mode.
|
||||
setTraverseMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
|
||||
setTraversalMode(NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
IntersectVisitor::~IntersectVisitor()
|
||||
{
|
||||
std::for_each(_intersectStateStack.begin(),_intersectStateStack.end(),UnrefOp<IntersectState>());
|
||||
_intersectStateStack.erase(_intersectStateStack.begin(),_intersectStateStack.end());
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::reset()
|
||||
{
|
||||
|
||||
//
|
||||
// first unref all referenced objects and then empty the containers.
|
||||
//
|
||||
std::for_each(_intersectStateStack.begin(),_intersectStateStack.end(),UnrefOp<IntersectState>());
|
||||
_intersectStateStack.erase(_intersectStateStack.begin(),_intersectStateStack.end());
|
||||
|
||||
|
||||
_intersectStateStack.clear();
|
||||
|
||||
// create a empty IntersectState on the the intersectStateStack.
|
||||
IntersectState* nis = new IntersectState;
|
||||
nis->_matrix = NULL;
|
||||
nis->_inverse = NULL;
|
||||
|
||||
|
||||
_intersectStateStack.push_back(nis);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool IntersectVisitor::hits()
|
||||
{
|
||||
for(SegHitListMap::iterator itr = _segHitList.begin();
|
||||
itr != _segHitList.end();
|
||||
++itr)
|
||||
for(LineSegmentHitListMap::iterator itr = _segHitList.begin();
|
||||
itr != _segHitList.end();
|
||||
++itr)
|
||||
{
|
||||
if (!(itr->second.empty())) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void IntersectVisitor::addSeg(Seg* seg)
|
||||
|
||||
|
||||
void IntersectVisitor::addLineSegment(LineSegment* seg)
|
||||
{
|
||||
// first check to see if segment has already been added.
|
||||
for(SegHitListMap::iterator itr = _segHitList.begin();
|
||||
itr != _segHitList.end();
|
||||
++itr)
|
||||
for(LineSegmentHitListMap::iterator itr = _segHitList.begin();
|
||||
itr != _segHitList.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->first == seg) return;
|
||||
}
|
||||
|
||||
// create a new segment transformed to local coordintes.
|
||||
IntersectState* cis = _intersectStateStack.back();
|
||||
Seg* ns = new Seg;
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
LineSegment* ns = new LineSegment;
|
||||
if (cis->_inverse) ns->mult(*seg,*(cis->_inverse));
|
||||
else *ns = *seg;
|
||||
cis->_segList.push_back(std::pair<Seg*,Seg*>(seg,ns));
|
||||
cis->_segList.push_back(std::pair<LineSegment*,LineSegment*>(seg,ns));
|
||||
seg->ref();
|
||||
ns->ref();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::pushMatrix(const Matrix& matrix)
|
||||
{
|
||||
IntersectState* nis = new IntersectState;
|
||||
nis->ref();
|
||||
|
||||
IntersectState* cis = _intersectStateStack.back();
|
||||
|
||||
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
|
||||
if (cis->_matrix)
|
||||
{
|
||||
nis->_matrix = new Matrix;
|
||||
@@ -252,18 +258,18 @@ void IntersectVisitor::pushMatrix(const Matrix& matrix)
|
||||
inverse_world->ref();
|
||||
inverse_world->invert(*(nis->_matrix));
|
||||
nis->_inverse = inverse_world;
|
||||
|
||||
IntersectState::SegmentMask segMaskIn = cis->_segmentMaskStack.back();
|
||||
IntersectState::SegmentMask mask = 0x00000001;
|
||||
for(IntersectState::SegList::iterator sitr=cis->_segList.begin();
|
||||
sitr!=cis->_segList.end();
|
||||
++sitr)
|
||||
|
||||
IntersectState::LineSegmentmentMask segMaskIn = cis->_segmentMaskStack.back();
|
||||
IntersectState::LineSegmentmentMask mask = 0x00000001;
|
||||
for(IntersectState::LineSegmentList::iterator sitr=cis->_segList.begin();
|
||||
sitr!=cis->_segList.end();
|
||||
++sitr)
|
||||
{
|
||||
if ((segMaskIn & mask))
|
||||
{
|
||||
Seg* seg = new Seg;
|
||||
LineSegment* seg = new LineSegment;
|
||||
seg->mult(*(sitr->first),*inverse_world);
|
||||
nis->_segList.push_back(std::pair<Seg*,Seg*>(sitr->first,seg));
|
||||
nis->_segList.push_back(std::pair<LineSegment*,LineSegment*>(sitr->first,seg));
|
||||
seg->ref();
|
||||
sitr->first->ref();
|
||||
}
|
||||
@@ -271,28 +277,30 @@ void IntersectVisitor::pushMatrix(const Matrix& matrix)
|
||||
}
|
||||
|
||||
_intersectStateStack.push_back(nis);
|
||||
|
||||
// notify(INFO) << << "IntersectVisitor::pushMatrix()"<<endl;
|
||||
|
||||
// notify(INFO) << << "IntersectVisitor::pushMatrix()"<<endl;
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::popMatrix()
|
||||
{
|
||||
if (!_intersectStateStack.empty())
|
||||
if (!_intersectStateStack.empty())
|
||||
{
|
||||
IntersectState* pvs = _intersectStateStack.back();
|
||||
pvs->unref();
|
||||
// IntersectState* pvs = _intersectStateStack.back().get();
|
||||
// pvs->unref();
|
||||
_intersectStateStack.pop_back();
|
||||
}
|
||||
// notify(INFO) << << "IntersectVisitor::popMatrix()"<<endl;
|
||||
// notify(INFO) << << "IntersectVisitor::popMatrix()"<<endl;
|
||||
}
|
||||
|
||||
|
||||
bool IntersectVisitor::enterNode(Node& node)
|
||||
{
|
||||
const BoundingSphere& bs = node.getBound();
|
||||
if (bs.isValid())
|
||||
{
|
||||
IntersectState* cis = _intersectStateStack.back();
|
||||
IntersectState::SegmentMask sm=0xffffffff;
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
IntersectState::LineSegmentmentMask sm=0xffffffff;
|
||||
if (cis->isCulled(bs,sm)) return false;
|
||||
cis->_segmentMaskStack.push_back(sm);
|
||||
_nodePath.push_back(&node);
|
||||
@@ -304,24 +312,27 @@ bool IntersectVisitor::enterNode(Node& node)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::leaveNode()
|
||||
{
|
||||
IntersectState* cis = _intersectStateStack.back();
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
cis->_segmentMaskStack.pop_back();
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::apply(Node& node)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
|
||||
|
||||
traverse(node);
|
||||
|
||||
leaveNode();
|
||||
}
|
||||
|
||||
|
||||
struct TriangleIntersect
|
||||
{
|
||||
Seg _seg;
|
||||
LineSegment _seg;
|
||||
|
||||
Vec3 _s;
|
||||
Vec3 _d;
|
||||
@@ -333,9 +344,8 @@ struct TriangleIntersect
|
||||
|
||||
typedef std::multimap<float,std::pair<int,osg::Vec3> > TriangleHitList;
|
||||
TriangleHitList _thl;
|
||||
|
||||
|
||||
TriangleIntersect(const Seg& seg,float ratio=FLT_MAX)
|
||||
TriangleIntersect(const LineSegment& seg,float ratio=FLT_MAX)
|
||||
{
|
||||
_seg=seg;
|
||||
_hit=false;
|
||||
@@ -348,19 +358,19 @@ struct TriangleIntersect
|
||||
_d /= _length;
|
||||
|
||||
}
|
||||
|
||||
// void operator () (const Vec3& v1,const Vec3& v2,const Vec3& v3)
|
||||
// {
|
||||
// float r;
|
||||
// if (_seg.intersect(v1,v2,v3,r))
|
||||
// {
|
||||
// _thl.insert(std::pair<float,int>(r,_index));
|
||||
// _hit = true;
|
||||
// }
|
||||
// ++_index;
|
||||
// }
|
||||
|
||||
// bool intersect(const Vec3& v1,const Vec3& v2,const Vec3& v3,float& r)
|
||||
// void operator () (const Vec3& v1,const Vec3& v2,const Vec3& v3)
|
||||
// {
|
||||
// float r;
|
||||
// if (_seg.intersect(v1,v2,v3,r))
|
||||
// {
|
||||
// _thl.insert(std::pair<float,int>(r,_index));
|
||||
// _hit = true;
|
||||
// }
|
||||
// ++_index;
|
||||
// }
|
||||
|
||||
// bool intersect(const Vec3& v1,const Vec3& v2,const Vec3& v3,float& r)
|
||||
void operator () (const Vec3& v1,const Vec3& v2,const Vec3& v3)
|
||||
{
|
||||
++_index;
|
||||
@@ -376,13 +386,12 @@ struct TriangleIntersect
|
||||
if (ds12<0.0f) return;
|
||||
if (ds12>d312) return;
|
||||
}
|
||||
else // d312 < 0
|
||||
else // d312 < 0
|
||||
{
|
||||
if (ds12>0.0f) return;
|
||||
if (ds12<d312) return;
|
||||
}
|
||||
|
||||
|
||||
Vec3 v23 = v3-v2;
|
||||
Vec3 n23 = v23^_d;
|
||||
float ds23 = (_s-v2)*n23;
|
||||
@@ -392,13 +401,12 @@ struct TriangleIntersect
|
||||
if (ds23<0.0f) return;
|
||||
if (ds23>d123) return;
|
||||
}
|
||||
else // d123 < 0
|
||||
else // d123 < 0
|
||||
{
|
||||
if (ds23>0.0f) return;
|
||||
if (ds23<d123) return;
|
||||
}
|
||||
|
||||
|
||||
Vec3 v31 = v1-v3;
|
||||
Vec3 n31 = v31^_d;
|
||||
float ds31 = (_s-v3)*n31;
|
||||
@@ -408,7 +416,7 @@ struct TriangleIntersect
|
||||
if (ds31<0.0f) return;
|
||||
if (ds31>d231) return;
|
||||
}
|
||||
else // d231 < 0
|
||||
else // d231 < 0
|
||||
{
|
||||
if (ds31>0.0f) return;
|
||||
if (ds31<d231) return;
|
||||
@@ -424,7 +432,6 @@ struct TriangleIntersect
|
||||
|
||||
float d = (in-_s)*_d;
|
||||
|
||||
|
||||
if (d<0.0f) return;
|
||||
if (d>_length) return;
|
||||
|
||||
@@ -433,28 +440,26 @@ struct TriangleIntersect
|
||||
|
||||
float r = d/_length;
|
||||
|
||||
_thl.insert(std::pair<float,std::pair<int,osg::Vec3> >
|
||||
(r,std::pair<int,osg::Vec3>(_index-1,normal)));
|
||||
_thl.insert(std::pair<const float,std::pair<int,osg::Vec3> > (r,std::pair<int,osg::Vec3>(_index-1,normal)));
|
||||
_hit = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
bool IntersectVisitor::intersect(GeoSet& gset)
|
||||
{
|
||||
bool hitFlag = false;
|
||||
|
||||
IntersectState* cis = _intersectStateStack.back();
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
|
||||
const BoundingBox& bb = gset.getBound();
|
||||
|
||||
for(IntersectState::SegList::iterator sitr=cis->_segList.begin();
|
||||
sitr!=cis->_segList.end();
|
||||
++sitr)
|
||||
for(IntersectState::LineSegmentList::iterator sitr=cis->_segList.begin();
|
||||
sitr!=cis->_segList.end();
|
||||
++sitr)
|
||||
{
|
||||
if (sitr->second->intersect(bb))
|
||||
if (sitr->second->intersect(bb))
|
||||
{
|
||||
TriangleIntersect ti(*sitr->second);
|
||||
for_each_triangle(gset,ti);
|
||||
@@ -462,8 +467,8 @@ bool IntersectVisitor::intersect(GeoSet& gset)
|
||||
{
|
||||
|
||||
for(TriangleIntersect::TriangleHitList::iterator thitr=ti._thl.begin();
|
||||
thitr!=ti._thl.end();
|
||||
++thitr)
|
||||
thitr!=ti._thl.end();
|
||||
++thitr)
|
||||
{
|
||||
Hit hit;
|
||||
hit._nodePath = _nodePath;
|
||||
@@ -475,26 +480,26 @@ bool IntersectVisitor::intersect(GeoSet& gset)
|
||||
|
||||
hit._ratio = thitr->first;
|
||||
hit._primitiveIndex = thitr->second.first;
|
||||
hit._originalSeg = sitr->first;
|
||||
if (hit._originalSeg) hit._originalSeg->ref();
|
||||
hit._localSeg = sitr->second;
|
||||
if (hit._localSeg) hit._localSeg->ref();
|
||||
hit._originalLineSegment = sitr->first;
|
||||
if (hit._originalLineSegment) hit._originalLineSegment->ref();
|
||||
hit._localLineSegment = sitr->second;
|
||||
if (hit._localLineSegment) hit._localLineSegment->ref();
|
||||
|
||||
hit._intersectPoint = sitr->second->start()*(1.0f-hit._ratio)+
|
||||
sitr->second->end()*hit._ratio;
|
||||
|
||||
sitr->second->end()*hit._ratio;
|
||||
|
||||
hit._intersectNormal = thitr->second.second;
|
||||
|
||||
// _segHitList[sitr->first].insert(hit);
|
||||
// _segHitList[sitr->first].insert(hit);
|
||||
_segHitList[sitr->first].push_back(hit);
|
||||
std::sort(_segHitList[sitr->first].begin(),_segHitList[sitr->first].end());
|
||||
std::sort(_segHitList[sitr->first].begin(),_segHitList[sitr->first].end());
|
||||
|
||||
hitFlag = true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// else notify(INFO) << << "no BB hit"<<endl;
|
||||
// else notify(INFO) << << "no BB hit"<<endl;
|
||||
}
|
||||
|
||||
return hitFlag;
|
||||
@@ -502,68 +507,69 @@ bool IntersectVisitor::intersect(GeoSet& gset)
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::apply(Geode& node)
|
||||
void IntersectVisitor::apply(Geode& geode)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
if (!enterNode(geode)) return;
|
||||
|
||||
|
||||
for(int i=0;i<node.getNumGeosets();++i)
|
||||
for(int i = 0; i < geode.getNumDrawables(); i++ )
|
||||
{
|
||||
|
||||
intersect(*node.getGeoSet(i));
|
||||
|
||||
osg::GeoSet* gset = dynamic_cast<osg::GeoSet*>(geode.getDrawable(i));
|
||||
if (gset) intersect(*gset);
|
||||
}
|
||||
|
||||
|
||||
leaveNode();
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::apply(Billboard& node)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
// Vec3 eye_local = getEyeLocal();
|
||||
// for(int i=0;i<node.getNumGeosets();++i)
|
||||
// {
|
||||
// Vec3 pos;
|
||||
// node.getPos(i,pos);
|
||||
//
|
||||
// GeoSet* gset = node.getGeoSet(i);
|
||||
//
|
||||
// Matrix local_mat;
|
||||
// node.calcTransform(eye_local,pos,local_mat);
|
||||
//
|
||||
// Matrix* matrix = NULL;
|
||||
// Matrix* currMatrix = getCurrentMatrix();
|
||||
// if (currMatrix)
|
||||
// {
|
||||
// matrix = new Matrix();
|
||||
// matrix->mult(local_mat,*(currMatrix));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// matrix = new Matrix(local_mat);
|
||||
// }
|
||||
//
|
||||
// matrix->ref();
|
||||
// matrix->unref();
|
||||
//
|
||||
// }
|
||||
// Vec3 eye_local = getEyeLocal();
|
||||
// for(int i=0;i<node.getNumGeosets();++i)
|
||||
// {
|
||||
// Vec3 pos;
|
||||
// node.getPos(i,pos);
|
||||
//
|
||||
// GeoSet* gset = node.getGeoSet(i);
|
||||
//
|
||||
// Matrix local_mat;
|
||||
// node.calcTransform(eye_local,pos,local_mat);
|
||||
//
|
||||
// Matrix* matrix = NULL;
|
||||
// Matrix* currMatrix = getCurrentMatrix();
|
||||
// if (currMatrix)
|
||||
// {
|
||||
// matrix = new Matrix();
|
||||
// matrix->mult(local_mat,*(currMatrix));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// matrix = new Matrix(local_mat);
|
||||
// }
|
||||
//
|
||||
// matrix->ref();
|
||||
// matrix->unref();
|
||||
//
|
||||
// }
|
||||
leaveNode();
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::apply(Group& node)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
|
||||
|
||||
traverse(node);
|
||||
|
||||
leaveNode();
|
||||
}
|
||||
|
||||
void IntersectVisitor::apply(DCS& node)
|
||||
|
||||
void IntersectVisitor::apply(Transform& node)
|
||||
{
|
||||
if (!enterNode(node)) return;
|
||||
|
||||
pushMatrix(*node.getMatrix());
|
||||
|
||||
pushMatrix(node.getMatrix());
|
||||
|
||||
traverse(node);
|
||||
|
||||
@@ -583,9 +589,3 @@ void IntersectVisitor::apply(LOD& node)
|
||||
{
|
||||
apply((Group&)node);
|
||||
}
|
||||
|
||||
|
||||
void IntersectVisitor::apply(Scene& node)
|
||||
{
|
||||
apply((Group&)node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user