Added the beginnings of a new osgforest example.
Added support into osg::TriangleFunctor for specifying whether the vertices being generates are temporary or not.
This commit is contained in:
@@ -241,7 +241,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
|
||||
double time=drawable->getReferenceTime();
|
||||
double timeInterval=drawable->getReferenceTimeInterval();
|
||||
|
||||
const osg::Polytope clipvol(cv->getModelViewCullingStack().back()->getFrustum());
|
||||
const osg::Polytope clipvol(cv->getCurrentCullingSet().getFrustum());
|
||||
const bool computeClipping = false;//(clipvol.getCurrentMask()!=0);
|
||||
|
||||
//LightPointDrawable::ColorPosition cp;
|
||||
|
||||
@@ -369,7 +369,7 @@ struct TriangleIntersect
|
||||
}
|
||||
|
||||
// bool intersect(const Vec3& v1,const Vec3& v2,const Vec3& v3,float& r)
|
||||
inline void operator () (const Vec3& v1,const Vec3& v2,const Vec3& v3)
|
||||
inline void operator () (const Vec3& v1,const Vec3& v2,const Vec3& v3, bool treatVertexDataAsTemporary)
|
||||
{
|
||||
++_index;
|
||||
|
||||
@@ -465,8 +465,15 @@ struct TriangleIntersect
|
||||
osg::notify(WARN)<<" ("<<r1<<",\t"<<r2<<",\t"<<r3<<")"<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_thl.insert(std::pair<const float,TriangleHit>(r,TriangleHit(_index-1,normal,r1,&v1,r2,&v2,r3,&v3)));
|
||||
|
||||
if (treatVertexDataAsTemporary)
|
||||
{
|
||||
_thl.insert(std::pair<const float,TriangleHit>(r,TriangleHit(_index-1,normal,r1,0,r2,0,r3,0)));
|
||||
}
|
||||
else
|
||||
{
|
||||
_thl.insert(std::pair<const float,TriangleHit>(r,TriangleHit(_index-1,normal,r1,&v1,r2,&v2,r3,&v3)));
|
||||
}
|
||||
_hit = true;
|
||||
|
||||
}
|
||||
|
||||
@@ -70,15 +70,18 @@ struct SmoothTriangleFunctor
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator() ( const osg::Vec3 &v1, const osg::Vec3 &v2, const osg::Vec3 &v3 )
|
||||
inline void operator() ( const osg::Vec3 &v1, const osg::Vec3 &v2, const osg::Vec3 &v3, bool treatVertexDataAsTemporary )
|
||||
{
|
||||
// calc orientation of triangle.
|
||||
osg::Vec3 normal = (v2-v1)^(v3-v1);
|
||||
// normal.normalize();
|
||||
if (!treatVertexDataAsTemporary)
|
||||
{
|
||||
// calc orientation of triangle.
|
||||
osg::Vec3 normal = (v2-v1)^(v3-v1);
|
||||
// normal.normalize();
|
||||
|
||||
updateNormal(normal,&v1);
|
||||
updateNormal(normal,&v2);
|
||||
updateNormal(normal,&v3);
|
||||
updateNormal(normal,&v1);
|
||||
updateNormal(normal,&v2);
|
||||
updateNormal(normal,&v3);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,15 +34,19 @@ struct TriangleAcumulatorFunctor
|
||||
|
||||
void setCoords( const Vec3* vbase ) { _vbase = vbase; }
|
||||
|
||||
inline void operator() ( const Vec3 &v1, const Vec3 &v2, const Vec3 &v3 )
|
||||
inline void operator() ( const Vec3 &v1, const Vec3 &v2, const Vec3 &v3, bool treatVertexDataAsTemporary )
|
||||
{
|
||||
int p1 = (int)(&v1-_vbase);
|
||||
int p2 = (int)(&v2-_vbase);
|
||||
int p3 = (int)(&v3-_vbase);
|
||||
if (p1==p2 || p1==p3 || p2==p3) return;
|
||||
in_indices.push_back(p1);
|
||||
in_indices.push_back(p2);
|
||||
in_indices.push_back(p3);
|
||||
|
||||
if (!treatVertexDataAsTemporary)
|
||||
{
|
||||
int p1 = (int)(&v1-_vbase);
|
||||
int p2 = (int)(&v2-_vbase);
|
||||
int p3 = (int)(&v3-_vbase);
|
||||
if (p1==p2 || p1==p3 || p2==p3) return;
|
||||
in_indices.push_back(p1);
|
||||
in_indices.push_back(p2);
|
||||
in_indices.push_back(p3);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user