OSGDistanceLOD.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 OSG_BEGIN_NAMESPACE
00038
00039 template<class RenderActionT> inline
00040 ActionBase::ResultE DistanceLOD::render(Action *action)
00041 {
00042 action->useNodeList();
00043
00044 Int32 numLevels = action->getNNodes();
00045
00046 if(numLevels == 0)
00047 return Action::Continue;
00048
00049 RenderActionT *ra = dynamic_cast<RenderActionT *>(action);
00050 Int32 index = -1;
00051
00052 const MFReal32 *range = getMFRange();
00053
00054 Int32 numRanges = range->size();
00055
00056 if (numRanges == 0)
00057 {
00058 index = 0;
00059 }
00060 else
00061 {
00062 Pnt3f eyepos;
00063
00064 ra->getActivePartition()->getCameraToWorld().mult(eyepos, eyepos);
00065
00066 Pnt3f objpos;
00067
00068 ra->topMatrix().mult(getCenter(), objpos);
00069
00070 Real32 dist = eyepos.dist(objpos);
00071
00072 if(numRanges >= numLevels)
00073 numRanges = numLevels - 1;
00074
00075 if(dist >= (*range)[numRanges - 1])
00076 {
00077 index = numRanges;
00078 }
00079 else
00080 {
00081 for(index = 0; index < numRanges; ++index)
00082 {
00083 if(dist < (*range)[index])
00084 break;
00085 }
00086 }
00087 }
00088
00089 Node *nodePtr = action->getNode(index);
00090
00091 if(ra->isVisible(nodePtr))
00092 {
00093 ra->addNode(nodePtr);
00094 }
00095
00096 return ActionBase::Continue;
00097 }
00098
00099 OSG_END_NAMESPACE
00100
00101