Ran script to remove trailing spaces and tabs

This commit is contained in:
Robert Osfield
2012-03-21 17:36:20 +00:00
parent 1e35f8975d
commit 14a563dc9f
1495 changed files with 21873 additions and 21873 deletions

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -18,7 +18,7 @@
using namespace osgSim;
BlinkSequence::BlinkSequence():
_pulsePeriod(0.0),
_pulsePeriod(0.0),
_phaseShift(0.0),
_pulseData(),
_sequenceGroup(0)
@@ -51,4 +51,4 @@ SequenceGroup::SequenceGroup(double baseTime):
_baseTime(baseTime)
{
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgSim/DOFTransform>
@@ -29,8 +29,8 @@ static const unsigned int SCALE_Z_LIMIT_BIT = 0x80000000u >> 8;
DOFTransform::DOFTransform():
_previousTraversalNumber(osg::UNINITIALIZED_FRAME_NUMBER),
_previousTime(0.0),
_limitationFlags(0),
_animationOn(false),
_limitationFlags(0),
_animationOn(false),
_increasingFlags(0xffff),
_multOrder(PRH)
{
@@ -59,7 +59,7 @@ DOFTransform::DOFTransform(const DOFTransform& dof, const osg::CopyOp& copyop):
_increasingFlags(dof._increasingFlags),
_multOrder(dof._multOrder)
{
if (_animationOn) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
if (_animationOn) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+1);
}
void DOFTransform::traverse(osg::NodeVisitor& nv)
@@ -76,7 +76,7 @@ void DOFTransform::traverse(osg::NodeVisitor& nv)
animate((float)(newTime-_previousTime));
_previousTraversalNumber = nv.getTraversalNumber();
_previousTime = newTime;
_previousTime = newTime;
}
}
@@ -89,7 +89,7 @@ bool DOFTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisito
osg::Matrix l2w(getPutMatrix());
//now the current matrix:
osg::Matrix current;
osg::Matrix current;
current.makeTranslate(getCurrentTranslate());
//now create the local rotation:
@@ -146,9 +146,9 @@ bool DOFTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisito
}
else
{
matrix = l2w;
matrix = l2w;
}
return true;
}
@@ -159,7 +159,7 @@ bool DOFTransform::computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisito
osg::Matrix w2l(getInversePutMatrix());
//now the current matrix:
osg::Matrix current;
osg::Matrix current;
current.makeTranslate(-getCurrentTranslate());
//now create the local rotation:
@@ -226,7 +226,7 @@ void DOFTransform::updateCurrentHPR(const osg::Vec3& hpr)
//if there is constrain on animation
if (_limitationFlags & ROTATION_ROLL_LIMIT_BIT)
{
//if we have min == max, it is efective constrain, so don't change
//if we have min == max, it is efective constrain, so don't change
if(_minHPR[2] != _maxHPR[2])
{
_currentHPR[2] = hpr[2];
@@ -234,7 +234,7 @@ void DOFTransform::updateCurrentHPR(const osg::Vec3& hpr)
if(_currentHPR[2] < _minHPR[2])
{
_currentHPR[2] = _minHPR[2];
_currentHPR[2] = _minHPR[2];
//force increasing flag to 1
_increasingFlags |= this_flag;
}
@@ -283,12 +283,12 @@ void DOFTransform::updateCurrentHPR(const osg::Vec3& hpr)
unsigned short this_flag = (unsigned short)1<<5;//heading
if(_currentHPR[0] < _minHPR[0])
if(_currentHPR[0] < _minHPR[0])
{
_currentHPR[0] = _minHPR[0];
_increasingFlags |= this_flag;
}
else if(_currentHPR[0] > _maxHPR[0])
else if(_currentHPR[0] > _maxHPR[0])
{
_currentHPR[0] = _maxHPR[0];
_increasingFlags &= ~this_flag;
@@ -318,7 +318,7 @@ void DOFTransform::updateCurrentTranslate(const osg::Vec3& translate)
_currentTranslate[2] = _minTranslate[2];
_increasingFlags |= this_flag;
}
else if(_currentTranslate[2] > _maxTranslate[2])
else if(_currentTranslate[2] > _maxTranslate[2])
{
_currentTranslate[2] = _maxTranslate[2];
_increasingFlags &= ~this_flag;
@@ -342,7 +342,7 @@ void DOFTransform::updateCurrentTranslate(const osg::Vec3& translate)
_currentTranslate[1] = _minTranslate[1];
_increasingFlags |= this_flag;
}
else if(_currentTranslate[1] > _maxTranslate[1])
else if(_currentTranslate[1] > _maxTranslate[1])
{
_currentTranslate[1] = _maxTranslate[1];
_increasingFlags &= ~this_flag;
@@ -361,18 +361,18 @@ void DOFTransform::updateCurrentTranslate(const osg::Vec3& translate)
_currentTranslate[0] = translate[0];
unsigned short this_flag = (unsigned short)1;
if(_currentTranslate[0] < _minTranslate[0])
if(_currentTranslate[0] < _minTranslate[0])
{
_currentTranslate[0] = _minTranslate[0];
_increasingFlags |= this_flag;
}
else if(_currentTranslate[0] > _maxTranslate[0])
else if(_currentTranslate[0] > _maxTranslate[0])
{
_currentTranslate[0] = _maxTranslate[0];
_increasingFlags &= ~this_flag;
}
}
}
}
else
{
_currentTranslate[0] = translate[0];
@@ -387,16 +387,16 @@ void DOFTransform::updateCurrentScale(const osg::Vec3& scale)
if (_limitationFlags & SCALE_Z_LIMIT_BIT)
{
if(_minScale[2] != _maxScale[2])
{
{
_currentScale[2] = scale[2];
unsigned short this_flag = (unsigned short)1<<8;
if(_currentScale[2] < _minScale[2])
if(_currentScale[2] < _minScale[2])
{
_currentScale[2] = _minScale[2];
_increasingFlags |= this_flag;
}
else if(_currentScale[2] > _maxScale[2])
else if(_currentScale[2] > _maxScale[2])
{
_currentScale[2] = _maxScale[2];
_increasingFlags &= ~this_flag;
@@ -415,12 +415,12 @@ void DOFTransform::updateCurrentScale(const osg::Vec3& scale)
_currentScale[1] = scale[1];
unsigned short this_flag = (unsigned short)1<<7;
if(_currentScale[1] < _minScale[1])
if(_currentScale[1] < _minScale[1])
{
_currentScale[1] = _minScale[1];
_increasingFlags |= this_flag;
}
else if(_currentScale[1] > _maxScale[1])
else if(_currentScale[1] > _maxScale[1])
{
_currentScale[1] = _maxScale[1];
_increasingFlags &= ~this_flag;
@@ -439,12 +439,12 @@ void DOFTransform::updateCurrentScale(const osg::Vec3& scale)
_currentScale[0] = scale[0];
unsigned short this_flag = (unsigned short)1<<6;
if(_currentScale[0] < _minScale[0])
if(_currentScale[0] < _minScale[0])
{
_currentScale[0] = _minScale[0];
_increasingFlags |= this_flag;
}
else if(_currentScale[0] > _maxScale[0])
else if(_currentScale[0] > _maxScale[0])
{
_currentScale[0] = _maxScale[0];
_increasingFlags &= ~this_flag;
@@ -462,14 +462,14 @@ void DOFTransform::updateCurrentScale(const osg::Vec3& scale)
void DOFTransform::setAnimationOn(bool do_animate)
{
if (_animationOn == do_animate) return;
int delta = 0;
if (_animationOn) --delta;
if (do_animate) ++delta;
_animationOn = do_animate;
if (_animationOn) setNumChildrenRequiringUpdateTraversal(getNumChildrenRequiringUpdateTraversal()+delta);
}
@@ -534,5 +534,5 @@ void DOFTransform::animate(float deltaTime)
new_value[2] -= _incrementScale[2]*deltaTime;
updateCurrentScale(new_value);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -22,7 +22,7 @@ using namespace osgSim;
HeightAboveTerrain::HeightAboveTerrain()
{
_lowestHeight = -1000.0;
setDatabaseCacheReadCallback(new DatabaseCacheReadCallback);
}
@@ -51,14 +51,14 @@ void HeightAboveTerrain::computeIntersections(osg::Node* scene, osg::Node::NodeM
{
if (em)
{
osg::Vec3d start = itr->_point;
osg::Vec3d upVector = em->computeLocalUpVector(start.x(), start.y(), start.z());
double latitude, longitude, height;
em->convertXYZToLatLongHeight(start.x(), start.y(), start.z(), latitude, longitude, height);
osg::Vec3d end = start - upVector * (height - _lowestHeight);
osg::Vec3d end = start - upVector * (height - _lowestHeight);
itr->_hat = height;
OSG_NOTICE<<"lat = "<<latitude<<" longitude = "<<longitude<<" height = "<<height<<std::endl;
@@ -70,9 +70,9 @@ void HeightAboveTerrain::computeIntersections(osg::Node* scene, osg::Node::NodeM
{
osg::Vec3d start = itr->_point;
osg::Vec3d upVector (0.0, 0.0, 1.0);
double height = start.z();
osg::Vec3d end = start - upVector * (height - _lowestHeight);
osg::Vec3d end = start - upVector * (height - _lowestHeight);
itr->_hat = height;
@@ -80,13 +80,13 @@ void HeightAboveTerrain::computeIntersections(osg::Node* scene, osg::Node::NodeM
intersectorGroup->addIntersector( intersector.get() );
}
}
_intersectionVisitor.reset();
_intersectionVisitor.setTraversalMask(traversalMask);
_intersectionVisitor.setIntersector( intersectorGroup.get() );
scene->accept(_intersectionVisitor);
unsigned int index = 0;
osgUtil::IntersectorGroup::Intersectors& intersectors = intersectorGroup->getIntersectors();
for(osgUtil::IntersectorGroup::Intersectors::iterator intersector_itr = intersectors.begin();
@@ -106,7 +106,7 @@ void HeightAboveTerrain::computeIntersections(osg::Node* scene, osg::Node::NodeM
}
}
}
}
double HeightAboveTerrain::computeHeightAboveTerrain(osg::Node* scene, const osg::Vec3d& point, osg::Node::NodeMask traversalMask)

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgSim/Impostor>
@@ -19,18 +19,18 @@ using namespace osgSim;
// use this cull callback to allow the camera to traverse the Impostor's children without
// actuall having them assigned as children to the camea itself. This make the camera a
// decorator without ever directly being assigned to it.
// decorator without ever directly being assigned to it.
class ImpostorTraverseNodeCallback : public osg::NodeCallback
{
public:
ImpostorTraverseNodeCallback(osgSim::Impostor* node):_node(node) {}
ImpostorTraverseNodeCallback(osgSim::Impostor* node):_node(node) {}
virtual void operator()(osg::Node*, osg::NodeVisitor* nv)
{
_node->LOD::traverse(*nv);
}
osgSim::Impostor* _node;
};
@@ -74,7 +74,7 @@ void Impostor::addImpostorSprite(unsigned int contextID, ImpostorSprite* is)
{
Impostor* previous_owner = is->getParent();
ImpostorSpriteList& isl = previous_owner->_impostorSpriteListBuffer[contextID];
// find and erase reference to is.
for(ImpostorSpriteList::iterator itr=isl.begin();
itr!=isl.end();
@@ -88,7 +88,7 @@ void Impostor::addImpostorSprite(unsigned int contextID, ImpostorSprite* is)
}
}
is->setParent(this);
}
}
@@ -119,11 +119,11 @@ void Impostor::traverse(osg::NodeVisitor& nv)
LOD::traverse(nv);
return;
}
osg::Vec3 eyeLocal = nv.getEyePoint();
const BoundingSphere& bs = getBound();
unsigned int contextID = cv->getState() ? cv->getState()->getContextID() : 0;
float distance2 = (eyeLocal-bs.center()).length2();
@@ -137,16 +137,16 @@ void Impostor::traverse(osg::NodeVisitor& nv)
LOD::traverse(nv);
}
else
{
{
// within the impostor distance threshold therefore attempt
// to use impostor instead.
RefMatrix& matrix = *cv->getModelViewMatrix();
// search for the best fit ImpostorSprite;
ImpostorSprite* impostorSprite = findBestImpostorSprite(contextID,eyeLocal);
if (impostorSprite)
{
// impostor found, now check to see if it is good enough to use
@@ -159,7 +159,7 @@ void Impostor::traverse(osg::NodeVisitor& nv)
impostorSprite=NULL;
}
}
// need to think about sprite reuse and support for multiple context's.
@@ -170,37 +170,37 @@ void Impostor::traverse(osg::NodeVisitor& nv)
// create the impostor sprite.
impostorSprite = createImpostorSprite(cv);
//if (impostorSprite) impostorSprite->_color.set(0.0f,0.0f,1.0f,1.0f);
}
//else impostorSprite->_color.set(1.0f,1.0f,1.0f,1.0f);
if (impostorSprite)
{
// update frame number to show that impostor is in action.
impostorSprite->setLastFrameUsed(cv->getTraversalNumber());
if (cv->getComputeNearFarMode()) cv->updateCalculatedNearFar(matrix,*impostorSprite, false);
StateSet* stateset = impostorSprite->getStateSet();
if (stateset) cv->pushStateSet(stateset);
cv->addDrawableAndDepth(impostorSprite, &matrix, distance(getCenter(),matrix));
if (stateset) cv->popStateSet();
}
else
{
// no impostor has been selected or created so default to
// no impostor has been selected or created so default to
// traversing the usual LOD selected child.
LOD::traverse(nv);
}
}
}
@@ -214,8 +214,8 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
impostorSpriteManager = new osgSim::ImpostorSpriteManager;
cv->setUserData(impostorSpriteManager);
}
// default to true right now, will dertermine if perspective from the
// projection matrix...
bool isPerspectiveProjection = true;
@@ -236,24 +236,24 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
float distance_local = lv_local.length();
lv_local /= distance_local;
Vec3 sv_local = lv_local^camera_up_local;
sv_local.normalize();
Vec3 up_local = sv_local^lv_local;
float width = bs.radius();
if (isPerspectiveProjection)
{
// expand the width to account for projection onto sprite.
width *= (distance_local/sqrtf(distance_local*distance_local-bs.radius2()));
}
// scale up and side vectors to sprite width.
up_local *= width;
sv_local *= width;
// create the corners of the sprite.
Vec3 c00(center_local - sv_local - up_local);
Vec3 c10(center_local + sv_local - up_local);
@@ -272,7 +272,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
float s = c11_win.x()-c00_win.x();
float t = c11_win.y()-c00_win.y();
// may need to reverse sign of width or height if a matrix has
// been applied which flips the orientation of this subgraph.
if (s<0.0f) s = -s;
@@ -281,7 +281,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
// bias value used to assist the rounding up or down of
// the texture dimensions to the nearest power of two.
// bias near 0.0 will almost always round down.
// bias near 1.0 will almost always round up.
// bias near 1.0 will almost always round up.
float bias = 0.7f;
float sp2 = logf((float)s)/logf(2.0f);
@@ -294,14 +294,14 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
const osg::Viewport& viewport = *(cv->getViewport());
// if dimension is bigger than window divide it down.
// if dimension is bigger than window divide it down.
while (new_s>viewport.width()) new_s /= 2;
// if dimension is bigger than window divide it down.
// if dimension is bigger than window divide it down.
while (new_t>viewport.height()) new_t /= 2;
// create the impostor sprite.
ImpostorSprite* impostorSprite =
ImpostorSprite* impostorSprite =
impostorSpriteManager->createOrReuseImpostorSprite(new_s,new_t,cv->getTraversalNumber()-cv->getNumberOfFrameToKeepImpostorSprites());
if (impostorSprite==NULL)
@@ -325,7 +325,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
StateSet* stateset = impostorSprite->getStateSet();
stateset->setRenderBinDetails(10,"DepthSortedBin");
}
osg::Texture2D* texture = impostorSprite->getTexture();
texture->setTextureSize(new_s, new_t);
@@ -338,7 +338,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
Vec3* coords = impostorSprite->getCoords();
Vec2* texcoords = impostorSprite->getTexCoords();
coords[0] = c01;
texcoords[0].set(0.0f,1.0f);
@@ -350,11 +350,11 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
coords[3] = c11;
texcoords[3].set(1.0f,1.0f);
impostorSprite->dirtyBound();
Vec3* controlcoords = impostorSprite->getControlCoords();
if (isPerspectiveProjection)
{
// deal with projection issue by moving the coorners of the quad
@@ -362,7 +362,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
float ratio = width/(center_local-eye_local).length();
float one_minus_ratio = 1.0f-ratio;
Vec3 eye_local_ratio = eye_local*ratio;
controlcoords[0] = coords[0]*one_minus_ratio + eye_local_ratio;
controlcoords[1] = coords[1]*one_minus_ratio + eye_local_ratio;
controlcoords[2] = coords[2]*one_minus_ratio + eye_local_ratio;
@@ -386,7 +386,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
Vec3 eye_world(0.0,0.0,0.0);
Vec3 center_world = bs.center()*matrix;
osg::Camera* camera = impostorSprite->getCamera();
if (!camera)
{
@@ -395,31 +395,31 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
}
camera->setCullCallback(new ImpostorTraverseNodeCallback(this));
osgUtil::RenderStage* previous_stage = cv->getRenderStage();
// set up the background color and clear mask.
osg::Vec4 clear_color = previous_stage->getClearColor();
clear_color[3] = 0.0f; // set thae alpha to zero.
camera->setClearColor(clear_color);
camera->setClearMask(previous_stage->getClearMask());
// adjust camera left,right,up,down to fit (in world coords)
Vec3 near_local ( center_local-lv_local*width );
Vec3 far_local ( center_local+lv_local*width );
Vec3 top_local ( center_local+up_local);
Vec3 right_local ( center_local+sv_local);
Vec3 near_world = near_local * matrix;
Vec3 far_world = far_local * matrix;
Vec3 top_world = top_local * matrix;
Vec3 right_world = right_local * matrix;
float znear = (near_world-eye_world).length();
float zfar = (far_world-eye_world).length();
float top = (top_world-center_world).length();
float right = (right_world-center_world).length();
@@ -444,15 +444,15 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
Vec3 rotate_from = bs.center()-eye_local;
Vec3 rotate_to = cv-> getLookVectorLocal();
osg::Matrix rotate_matrix =
osg::Matrix::translate(-eye_local)*
osg::Matrix rotate_matrix =
osg::Matrix::translate(-eye_local)*
osg::Matrix::rotate(rotate_from,rotate_to)*
osg::Matrix::translate(eye_local)*
*cv->getModelViewMatrix();
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(rotate_matrix);
camera->setViewport(0,0,new_s,new_t);
// tell the camera to use OpenGL frame buffer object where supported.
@@ -466,7 +466,7 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv)
// do the cull traversal on the subgraph
camera->accept(*cv);
return impostorSprite;
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#if defined(_MSC_VER)
@@ -82,9 +82,9 @@ float ImpostorSprite::calcPixelError(const osg::Matrix& MVPW) const
float dy = (projected_coord.y()-projected_control.y());
float error_sqrd = dx*dx+dy*dy;
if (error_sqrd > max_error_sqrd) max_error_sqrd = error_sqrd;
}
return sqrtf(max_error_sqrd);
@@ -154,7 +154,7 @@ void ImpostorSprite::accept(osg::PrimitiveFunctor& functor) const
{
functor.setVertexArray(4,_coords);
functor.drawArrays( GL_QUADS, 0, 4);
}
@@ -171,7 +171,7 @@ ImpostorSpriteManager::ImpostorSpriteManager():
_alphafunc = new osg::AlphaFunc;
_alphafunc->setFunction( osg::AlphaFunc::GREATER, 0.000f );
_reuseStateSetIndex = 0;
}
@@ -186,7 +186,7 @@ ImpostorSpriteManager::~ImpostorSpriteManager()
_first->_next = NULL;
_first = next;
}
}
void ImpostorSpriteManager::push_back(ImpostorSprite* is)
@@ -253,7 +253,7 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,u
if (!empty())
{
// search for a valid impostor to reuse.
// search for a valid impostor to reuse.
ImpostorSprite* curr = _first;
while (curr)
{
@@ -273,7 +273,7 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,u
}
// creating new impostor sprite.
osg::StateSet* stateset = new osg::StateSet;
@@ -310,7 +310,7 @@ ImpostorSprite* ImpostorSpriteManager::createOrReuseImpostorSprite(int s,int t,u
is->setTexture(texture,s,t);
push_back(is);
return is;
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#if defined(_MSC_VER)
@@ -45,7 +45,7 @@ void InsertImpostorsVisitor::apply(Node& node)
void InsertImpostorsVisitor::apply(Group& node)
{
_groupList.push_back(&node);
++_numNestedImpostors;
if (_numNestedImpostors<_maximumNumNestedImpostors)
{
@@ -60,7 +60,7 @@ void InsertImpostorsVisitor::apply(LOD& node)
{
_lodList.push_back(&node);
}
++_numNestedImpostors;
if (_numNestedImpostors<_maximumNumNestedImpostors)
{
@@ -103,7 +103,7 @@ void InsertImpostorsVisitor::insertImpostors()
// standard LOD settings
impostor->addChild(group);
impostor->setRange(0,0.0f,1e7f);
// impostor specfic settings.
impostor->setImpostorThresholdToBound(_impostorThresholdRatio);
@@ -119,9 +119,9 @@ void InsertImpostorsVisitor::insertImpostors()
}
}
}
}
}
// handle LOD's
if (_replaceLODsByImpostors)
@@ -153,7 +153,7 @@ void InsertImpostorsVisitor::insertImpostors()
impostor->addChild(lod->getChild(ci));
impostor->setRange(ci,lod->getMinRange(ci),lod->getMaxRange(ci));
}
impostor->setCenter(lod->getCenter());
impostor->setCenterMode(lod->getCenterMode());
@@ -172,6 +172,6 @@ void InsertImpostorsVisitor::insertImpostors()
}
}
}
}
}
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -37,7 +37,7 @@ LightPoint::LightPoint(const osg::Vec3& position,const osg::Vec4& color):
_blinkSequence(0),
_blendingMode(BLENDED)
{
}
}
LightPoint::LightPoint(bool on,
const osg::Vec3& position,
@@ -80,6 +80,6 @@ LightPoint& LightPoint::operator = (const LightPoint& lp)
_sector = lp._sector;
_blinkSequence = lp._blinkSequence;
_blendingMode = lp._blendingMode;
return *this;
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -25,7 +25,7 @@ LightPointDrawable::LightPointDrawable():
{
setSupportsDisplayList(false);
_depthOff = new osg::Depth;
_depthOff->setWriteMask(false);
@@ -34,7 +34,7 @@ LightPointDrawable::LightPointDrawable():
_blendOne = new osg::BlendFunc;
_blendOne->setFunction(osg::BlendFunc::SRC_ALPHA,osg::BlendFunc::ONE);
_blendOneMinusSrcAlpha = new osg::BlendFunc;
_blendOneMinusSrcAlpha->setFunction(osg::BlendFunc::SRC_ALPHA,osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
@@ -64,7 +64,7 @@ void LightPointDrawable::reset()
if (!itr->empty())
itr->erase(itr->begin(),itr->end());
}
for(itr=_sizedAdditiveLightPointList.begin();
itr!=_sizedAdditiveLightPointList.end();
++itr)
@@ -93,7 +93,7 @@ void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
state.applyMode(GL_LIGHTING,false);
state.applyTextureMode(0,GL_TEXTURE_1D,false);
state.applyTextureMode(0,GL_TEXTURE_2D,false);
glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
state.applyAttribute(_depthOn.get());
@@ -140,7 +140,7 @@ void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
}
state.applyAttribute(_blendOne.get());
state.applyAttribute(_blendOne.get());
for(pointsize=1,sitr=_sizedAdditiveLightPointList.begin();
sitr!=_sizedAdditiveLightPointList.end();
@@ -159,14 +159,14 @@ void LightPointDrawable::drawImplementation(osg::RenderInfo& renderInfo) const
}
glPointSize(1);
glHint(GL_POINT_SMOOTH_HINT,GL_FASTEST);
state.haveAppliedAttribute(osg::StateAttribute::POINT);
state.dirtyAllVertexArrays();
state.disableAllVertexArrays();
// restore the state afterwards.
state.apply();
#else

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -106,7 +106,7 @@ osg::BoundingSphere LightPointNode::computeBound() const
bsphere.set(_bbox.center(),0.0f);
for(itr=_lightPointList.begin();
itr!=_lightPointList.end();
++itr)
@@ -135,22 +135,22 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
osg::Timer_t t1=0,t2=0,t3=0,t4=0,t5=0,t6=0,t7=0,t8=0;
#endif
#ifdef USE_TIMER
t1 = timer.tick();
#endif
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(&nv);
#ifdef USE_TIMER
t2 = timer.tick();
#endif
// should we disable small feature culling here?
if (cv /*&& !cv->isCulled(_bbox)*/)
{
osg::Matrix matrix = *(cv->getModelViewMatrix());
osg::RefMatrix& projection = *(cv->getProjectionMatrix());
osgUtil::StateGraph* rg = cv->getCurrentStateGraph();
@@ -162,7 +162,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
// so need to add it.
cv->getCurrentRenderBin()->addStateGraph(rg);
}
#ifdef USE_TIMER
t3 = timer.tick();
#endif
@@ -193,7 +193,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
{
drawable = _pointSprites ? new LightPointSpriteDrawable : new LightPointDrawable;
rg->setUserData(drawable);
if (cv->getFrameStamp())
{
drawable->setSimulationTime(cv->getFrameStamp()->getSimulationTime());
@@ -207,10 +207,10 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
litr != rg->_leaves.end() && (*litr)->_drawable.get()!=drawable;
++litr)
{}
if (litr == rg->_leaves.end())
{
// haven't found the drawable added in the RenderLeaf list, therefore this may be the
// haven't found the drawable added in the RenderLeaf list, therefore this may be the
// first time through LightPointNode in this frame, so need to add drawable into the StateGraph RenderLeaf list
// and update its time signatures.
@@ -234,17 +234,17 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
t7 = timer.tick();
#endif
if (cv->getComputeNearFarMode() != osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR)
cv->updateCalculatedNearFar(matrix,_bbox);
const float minimumIntensity = 1.0f/256.0f;
const osg::Vec3 eyePoint = cv->getEyeLocal();
double time=drawable->getSimulationTime();
double timeInterval=drawable->getSimulationTimeInterval();
const osg::Polytope clipvol(cv->getCurrentCullingSet().getFrustum());
const bool computeClipping = false;//(clipvol.getCurrentMask()!=0);
@@ -254,7 +254,7 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
++itr)
{
const LightPoint& lp = *itr;
if (!lp._on) continue;
const osg::Vec3& position = lp._position;
@@ -392,11 +392,11 @@ void LightPointNode::traverse(osg::NodeVisitor& nv)
}
}
}
#ifdef USE_TIMER
t8 = timer.tick();
#endif
}
#ifdef USE_TIMER
cout << "compute"<<endl;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -96,7 +96,7 @@ void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) c
}
state.applyAttribute(_blendOne.get());
state.applyAttribute(_blendOne.get());
for(pointsize=1,sitr=_sizedAdditiveLightPointList.begin();
sitr!=_sizedAdditiveLightPointList.end();
@@ -115,14 +115,14 @@ void LightPointSpriteDrawable::drawImplementation(osg::RenderInfo& renderInfo) c
}
glPointSize(1);
glHint(GL_POINT_SMOOTH_HINT,GL_FASTEST);
state.haveAppliedAttribute(osg::StateAttribute::POINT);
state.dirtyAllVertexArrays();
state.disableAllVertexArrays();
// restore the state afterwards.
state.apply();
#else

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -39,24 +39,24 @@ osg::Node* DatabaseCacheReadCallback::readNodeFile(const std::string& filename)
// first check to see if file is already loaded.
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
FileNameSceneMap::iterator itr = _filenameSceneMap.find(filename);
if (itr != _filenameSceneMap.end())
{
OSG_INFO<<"Getting from cache "<<filename<<std::endl;
return itr->second.get();
}
}
// now load the file.
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(filename);
// insert into the cache.
if (node.valid())
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (_filenameSceneMap.size() < _maxNumFilesToCache)
{
OSG_INFO<<"Inserting into cache "<<filename<<std::endl;
@@ -83,7 +83,7 @@ osg::Node* DatabaseCacheReadCallback::readNodeFile(const std::string& filename)
_filenameSceneMap[filename] = node;
}
}
return node.release();
}
@@ -115,13 +115,13 @@ void LineOfSight::computeIntersections(osg::Node* scene, osg::Node::NodeMask tra
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector = new osgUtil::LineSegmentIntersector(itr->_start, itr->_end);
intersectorGroup->addIntersector( intersector.get() );
}
_intersectionVisitor.reset();
_intersectionVisitor.setTraversalMask(traversalMask);
_intersectionVisitor.setIntersector( intersectorGroup.get() );
scene->accept(_intersectionVisitor);
unsigned int index = 0;
osgUtil::IntersectorGroup::Intersectors& intersectors = intersectorGroup->getIntersectors();
for(osgUtil::IntersectorGroup::Intersectors::iterator intersector_itr = intersectors.begin();
@@ -133,9 +133,9 @@ void LineOfSight::computeIntersections(osg::Node* scene, osg::Node::NodeMask tra
{
Intersections& intersectionsLOS = _LOSList[index]._intersections;
_LOSList[index]._intersections.clear();
osgUtil::LineSegmentIntersector::Intersections& intersections = lsi->getIntersections();
for(osgUtil::LineSegmentIntersector::Intersections::iterator itr = intersections.begin();
itr != intersections.end();
++itr)
@@ -146,7 +146,7 @@ void LineOfSight::computeIntersections(osg::Node* scene, osg::Node::NodeMask tra
}
}
}
}
LineOfSight::Intersections LineOfSight::computeIntersections(osg::Node* scene, const osg::Vec3d& start, const osg::Vec3d& end, osg::Node::NodeMask traversalMask)

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgSim/MultiSwitch>
@@ -35,7 +35,7 @@ void MultiSwitch::traverse(osg::NodeVisitor& nv)
{
if (nv.getTraversalMode()==osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN)
{
if (_activeSwitchSet<_values.size())
{
for(unsigned int pos=0;pos<_children.size();++pos)
@@ -90,7 +90,7 @@ bool MultiSwitch::insertChild( unsigned int index, osg::Node *child)
}
}
return true;
}
return false;
@@ -101,7 +101,7 @@ bool MultiSwitch::removeChild( osg::Node *child )
// find the child's position.
unsigned int pos=getChildIndex(child);
if (pos==_children.size()) return false;
for(SwitchSetList::iterator itr=_values.begin();
itr!=_values.end();
++itr)
@@ -109,8 +109,8 @@ bool MultiSwitch::removeChild( osg::Node *child )
ValueList& values = *itr;
values.erase(values.begin()+pos);
}
return Group::removeChild(child);
return Group::removeChild(child);
}
void MultiSwitch::setValue(unsigned int switchSet, unsigned int pos,bool value)
@@ -129,7 +129,7 @@ void MultiSwitch::setChildValue(const osg::Node* child,unsigned int switchSet, b
// find the child's position.
unsigned int pos=getChildIndex(child);
if (pos==_children.size()) return;
ValueList& values = _values[switchSet];
values[pos]=value;
}
@@ -151,7 +151,7 @@ bool MultiSwitch::getChildValue(const osg::Node* child, unsigned int switchSet)
// find the child's position.
unsigned int pos=getChildIndex(child);
if (pos==_children.size()) return false;
const ValueList& values = _values[switchSet];
return values[pos];
}

File diff suppressed because it is too large Load Diff

View File

@@ -122,9 +122,9 @@ void ScalarBar::createDrawables()
{
// Remove any existing Drawables
_drawables.erase(_drawables.begin(), _drawables.end());
if (_numColors==0) return;
osg::Matrix matrix;
if(_orientation==HORIZONTAL)
{

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -18,7 +18,7 @@ using namespace osgSim;
//
// Elevation Range
// Elevation Range
//
void AzimRange::setAzimuthRange(float minAzimuth,float maxAzimuth,float fadeAngle)
@@ -58,7 +58,7 @@ void AzimRange::getAzimuthRange(float& minAzimuth, float& maxAzimuth, float& fad
//
// Elevation Range
// Elevation Range
//
void ElevationRange::setElevationRange(float minElevation,float maxElevation,float fadeAngle)
{
@@ -286,7 +286,7 @@ void DirectionalSector::setFadeAngle(float angle)
float ang = acos(_cosHorizAngle)+angle ;
if ( ang > osg::PI ) _cosHorizFadeAngle = -1.0 ;
else _cosHorizFadeAngle = cos(ang);
ang = acos(_cosVertAngle)+angle ;
if ( ang > osg::PI ) _cosVertFadeAngle = -1.0 ;
else _cosVertFadeAngle = cos(ang);
@@ -298,15 +298,15 @@ float DirectionalSector::getFadeAngle() const
}
float DirectionalSector::operator() (const osg::Vec3& eyeLocal) const
{
{
float elev_intensity, azim_intensity ;
// Tranform eyeLocal into the LightPoint frame
osg::Vec3 EPlp = _local_to_LP * eyeLocal ;
/*fprintf(stderr, " eyeLocal = %f, %f, %f\n", eyeLocal[0], eyeLocal[1], eyeLocal[2]) ;
fprintf(stderr, " EPlp = %f, %f, %f\n", EPlp[0], EPlp[1], EPlp[2]) ;*/
// Elevation check
// Project EPlp into LP YZ plane and dot with LPy
osg::Vec2 EPyz(EPlp[1], EPlp[2]) ;
@@ -330,7 +330,7 @@ float DirectionalSector::operator() (const osg::Vec3& eyeLocal) const
//fprintf(stderr, " >> fully inside el range\n") ;
}
// Elevation check passed
// Azimuth check
// Project EPlp into LP XY plane and dot with LPy
osg::Vec2 EPxy(EPlp[0], EPlp[1]) ;
@@ -356,7 +356,7 @@ float DirectionalSector::operator() (const osg::Vec3& eyeLocal) const
azim_intensity = 1.0 ;
}
// Azimuth check passed
// We're good! Return full intensity
//fprintf(stderr, " %%%% Returing intensity = %f\n", elev_intensity * azim_intensity) ;
return elev_intensity * azim_intensity ;

View File

@@ -35,7 +35,7 @@ ShapeAttribute::ShapeAttribute(const char * name, int value) :
_type(INTEGER),
_integer(value)
{}
ShapeAttribute::ShapeAttribute(const char * name, double value) :
_name(name),
_type(DOUBLE),
@@ -53,16 +53,16 @@ ShapeAttribute::ShapeAttribute(const ShapeAttribute & sa)
{
copy(sa);
}
ShapeAttribute::~ShapeAttribute()
{
free();
free();
}
void ShapeAttribute::free()
{
if ((_type == STRING) && (_string))
if ((_type == STRING) && (_string))
{
::free(_string);
_string = 0;
@@ -71,8 +71,8 @@ void ShapeAttribute::free()
void ShapeAttribute::setValue(const char * value)
{
free();
_type = STRING;
free();
_type = STRING;
_string = (value ? strdup(value) : 0);
}
@@ -110,10 +110,10 @@ void ShapeAttribute::copy(const ShapeAttribute& sa)
ShapeAttribute& ShapeAttribute::operator = (const ShapeAttribute& sa)
{
if (&sa == this) return *this;
free();
copy(sa);
return *this;
}
@@ -122,13 +122,13 @@ int ShapeAttribute::compare(const osgSim::ShapeAttribute& sa) const
{
if (_name<sa._name) return -1;
if (sa._name<_name) return 1;
if (_type<sa._type) return -1;
if (sa._type<_type) return 1;
if (_name<sa._name) return -1;
if (sa._name<_name) return 1;
switch (_type)
{
case STRING:
@@ -157,11 +157,11 @@ int ShapeAttribute::compare(const osgSim::ShapeAttribute& sa) const
int ShapeAttributeList::compare(const osgSim::ShapeAttributeList& sal) const
{
const_iterator salIt, thisIt, thisEnd = end();
int ret;
for (thisIt = begin(), salIt = sal.begin(); thisIt!= thisEnd; ++thisIt, ++salIt)
if ((ret = thisIt->compare(*salIt)) != 0) return ret;
if ((ret = thisIt->compare(*salIt)) != 0) return ret;
return 0;
}

View File

@@ -229,7 +229,7 @@ protected:
//getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF);
}
virtual osg::BoundingBox computeBound() const;
private:
@@ -304,7 +304,7 @@ void SphereSegment::setArea(const osg::Vec3& v, float azRange, float elevRange)
_elevMin = elev - elevRange;
_elevMax = elev + elevRange;
// Calculate the azimuth range, cater for trig ambiguities
// Calculate the azimuth range, cater for trig ambiguities
float az = atan2(vec.x(), vec.y());
azRange /= 2.0f;
@@ -908,7 +908,7 @@ struct ActivateTransparencyOnType
}
const std::type_info& _t;
protected:
ActivateTransparencyOnType& operator = (const ActivateTransparencyOnType&) { return *this; }
@@ -930,7 +930,7 @@ struct DeactivateTransparencyOnType
}
const std::type_info& _t;
protected:
DeactivateTransparencyOnType& operator = (const DeactivateTransparencyOnType&) { return *this; }
@@ -983,10 +983,10 @@ void SphereSegment::setAllColors(const osg::Vec4& c)
class PolytopeVisitor : public osg::NodeVisitor
{
public:
typedef std::pair<osg::Matrix, osg::Polytope> MatrixPolytopePair;
typedef std::vector<MatrixPolytopePair> PolytopeStack;
struct Hit
{
Hit(const osg::Matrix& matrix, osg::NodePath& nodePath, osg::Drawable* drawable):
@@ -998,7 +998,7 @@ class PolytopeVisitor : public osg::NodeVisitor
osg::NodePath _nodePath;
osg::ref_ptr<osg::Drawable> _drawable;
};
typedef std::vector<Hit> HitList;
@@ -1009,7 +1009,7 @@ class PolytopeVisitor : public osg::NodeVisitor
_polytopeStack.back().first = matrix;
_polytopeStack.back().second.setAndTransformProvidingInverse(polytope, _polytopeStack.back().first);
}
META_NodeVisitor("osgSim","PolytopeVisitor")
void reset()
@@ -1017,7 +1017,7 @@ class PolytopeVisitor : public osg::NodeVisitor
_polytopeStack.clear();
_hits.clear();
}
void apply(osg::Node& node)
{
if (_polytopeStack.back().second.contains(node.getBound()))
@@ -1034,13 +1034,13 @@ class PolytopeVisitor : public osg::NodeVisitor
osg::Matrix matrix = _polytopeStack.back().first;
transform.computeLocalToWorldMatrix(matrix, this);
_polytopeStack.push_back(MatrixPolytopePair());
_polytopeStack.back().first = matrix;
_polytopeStack.back().second.setAndTransformProvidingInverse(polytope, matrix);
traverse(transform);
_polytopeStack.back();
}
}
@@ -1057,7 +1057,7 @@ class PolytopeVisitor : public osg::NodeVisitor
}
}
traverse(node);
}
}
@@ -1065,7 +1065,7 @@ class PolytopeVisitor : public osg::NodeVisitor
HitList& getHits() { return _hits; }
protected:
PolytopeStack _polytopeStack;
HitList _hits;
@@ -1075,21 +1075,21 @@ class PolytopeVisitor : public osg::NodeVisitor
SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& transform, osg::Node* subgraph)
{
OSG_INFO<<"Creating line intersection between sphere segment and subgraph."<<std::endl;
osg::BoundingBox bb = getBoundingBox();
osg::Polytope polytope;
polytope.add(osg::Plane(1.0,0.0,0.0,-bb.xMin()));
polytope.add(osg::Plane(-1.0,0.0,0.0,bb.xMax()));
polytope.add(osg::Plane(0.0,1.0,0.0,-bb.yMin()));
polytope.add(osg::Plane(0.0,-1.0,0.0,bb.yMax()));
polytope.add(osg::Plane(0.0,0.0,1.0,-bb.zMin()));
polytope.add(osg::Plane(0.0,0.0,-1.0,bb.zMax()));
polytope.add(osg::Plane(1.0,0.0,0.0,-bb.xMin()));
polytope.add(osg::Plane(-1.0,0.0,0.0,bb.xMax()));
polytope.add(osg::Plane(0.0,1.0,0.0,-bb.yMin()));
polytope.add(osg::Plane(0.0,-1.0,0.0,bb.yMax()));
polytope.add(osg::Plane(0.0,0.0,1.0,-bb.zMin()));
polytope.add(osg::Plane(0.0,0.0,-1.0,bb.zMax()));
osg::Plane pl;
pl.set(osg::Vec3(-1.0,0.0,0.0), bb.corner(0));
PolytopeVisitor polytopeVisitor(transform, polytope);
subgraph->accept(polytopeVisitor);
if (polytopeVisitor.getHits().empty())
@@ -1111,7 +1111,7 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& t
SphereSegment::LineList lines = computeIntersection(itr->_matrix, itr->_drawable.get());
all_lines.insert(all_lines.end(), lines.begin(), lines.end());
}
// join all the lines that have ends that are close together..
return all_lines;
@@ -1120,21 +1120,21 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& t
osg::Node* SphereSegment::computeIntersectionSubgraph(const osg::Matrixd& transform, osg::Node* subgraph)
{
OSG_INFO<<"Creating line intersection between sphere segment and subgraph."<<std::endl;
osg::BoundingBox bb = getBoundingBox();
osg::Polytope polytope;
polytope.add(osg::Plane(1.0,0.0,0.0,-bb.xMin()));
polytope.add(osg::Plane(-1.0,0.0,0.0,bb.xMax()));
polytope.add(osg::Plane(0.0,1.0,0.0,-bb.yMin()));
polytope.add(osg::Plane(0.0,-1.0,0.0,bb.yMax()));
polytope.add(osg::Plane(0.0,0.0,1.0,-bb.zMin()));
polytope.add(osg::Plane(0.0,0.0,-1.0,bb.zMax()));
polytope.add(osg::Plane(1.0,0.0,0.0,-bb.xMin()));
polytope.add(osg::Plane(-1.0,0.0,0.0,bb.xMax()));
polytope.add(osg::Plane(0.0,1.0,0.0,-bb.yMin()));
polytope.add(osg::Plane(0.0,-1.0,0.0,bb.yMax()));
polytope.add(osg::Plane(0.0,0.0,1.0,-bb.zMin()));
polytope.add(osg::Plane(0.0,0.0,-1.0,bb.zMax()));
osg::Plane pl;
pl.set(osg::Vec3(-1.0,0.0,0.0), bb.corner(0));
PolytopeVisitor polytopeVisitor(transform, polytope);
subgraph->accept(polytopeVisitor);
if (polytopeVisitor.getHits().empty())
@@ -1155,7 +1155,7 @@ osg::Node* SphereSegment::computeIntersectionSubgraph(const osg::Matrixd& transf
{
group->addChild(computeIntersectionSubgraph(itr->_matrix, itr->_drawable.get()));
}
// join all the lines that have ends that are close together..
return group;
@@ -1188,7 +1188,7 @@ namespace SphereSegmentIntersector
VertexArray& _vertices;
protected:
SortFunctor& operator = (const SortFunctor&) { return *this; }
};
@@ -1375,7 +1375,7 @@ namespace SphereSegmentIntersector
double azimRange = (azimMax-azimMin)*0.5;
double rad2 = vertex.length2();
double length_xy = sqrtf(vertex.x()*vertex.x() + vertex.y()*vertex.y());
double length_xy = sqrtf(vertex.x()*vertex.x() + vertex.y()*vertex.y());
double elevation = atan2((double)vertex.z(),length_xy);
// radius surface
@@ -1494,7 +1494,7 @@ namespace SphereSegmentIntersector
// if all the vertices on all the sides and inside then we are completely inside
if (_inside_radiusSurface==_numVertices &&
_inside_leftRightSurfaces==_numVertices &&
_inside_topSurface==_numVertices &&
_inside_topSurface==_numVertices &&
_inside_bottomSurface==_numVertices) return Region::INSIDE;
return Region::INTERSECTS;
@@ -1512,8 +1512,8 @@ namespace SphereSegmentIntersector
// if all the vertices on all the sides and inside then we are completely inside
if ((surfaceType!=RADIUS_SURFACE && _inside_radiusSurface!=0) &&
(surfaceType!=LEFT_SURFACE && _inside_leftSurface!=0) &&
(surfaceType!=RIGHT_SURFACE && _inside_rightSurface!=0) &&
(surfaceType!=TOP_SURFACE && _inside_topSurface!=0) &&
(surfaceType!=RIGHT_SURFACE && _inside_rightSurface!=0) &&
(surfaceType!=TOP_SURFACE && _inside_topSurface!=0) &&
(surfaceType!=BOTTOM_SURFACE && _inside_bottomSurface!=0)) return false;
return true;
@@ -1574,7 +1574,7 @@ namespace SphereSegmentIntersector
EdgeSet _edges;
osg::Vec3 _centre;
double _radius;
double _radius;
double _azMin, _azMax, _elevMin, _elevMax;
unsigned int _numOutside;
@@ -1614,7 +1614,7 @@ namespace SphereSegmentIntersector
if (classification==Region::OUTSIDE)
{
++_numOutside;
return;
return;
}
if (rc.numberOfIntersectingSurfaces()==0)
@@ -1789,7 +1789,7 @@ namespace SphereSegmentIntersector
EdgeSet::iterator itr = _edges.find(edge);
if (itr==_edges.end())
{
edge->addTriangle(tri);
edge->addTriangle(tri);
_edges.insert(edge);
return edge.get();
}
@@ -1996,7 +1996,7 @@ namespace SphereSegmentIntersector
}
// handle a paired of surfaces that work to enclose a convex region, which means that
// handle a paired of surfaces that work to enclose a convex region, which means that
// points can be inside either surface to be valid, and be outside both surfaces to be invalid.
template<class I>
void trim(SphereSegment::LineList& lineList, osg::Vec3Array* sourceLine, I intersector1, I intersector2)
@@ -2076,7 +2076,7 @@ namespace SphereSegmentIntersector
possible1 = true;
possible2 = false;
}
else
else
{
OSG_INFO<<"start point, 2 near to end than 1"<<std::endl;
possible1 = false;
@@ -2139,7 +2139,7 @@ namespace SphereSegmentIntersector
possible1 = true;
possible2 = false;
}
else
else
{
OSG_INFO<<"end point, 2 near to end than 1"<<std::endl;
possible1 = false;
@@ -2292,7 +2292,7 @@ namespace SphereSegmentIntersector
_neighbourLineEnd = _neighbourLine->size()-1;
_distance = distance;
}
}
}
}
};
@@ -2335,7 +2335,7 @@ namespace SphereSegmentIntersector
while (unfusedLines.size()>=1)
{
// generate a set of line pairs to establish which
// generate a set of line pairs to establish which
// line pair has the minimum distance.
typedef std::multiset<LinePair> LinePairSet;
LinePairSet linePairs;
@@ -2352,7 +2352,7 @@ namespace SphereSegmentIntersector
linePairs.insert(linePair);
}
}
if (linePairs.empty())
{
OSG_INFO<<"Line Pairs empty"<<std::endl;
@@ -2420,7 +2420,7 @@ namespace SphereSegmentIntersector
// copy across all but fuse end of line1
for(int i=openEnd1;
i != fuseEnd1;
i != fuseEnd1;
i += direction1)
{
newline->push_back((*line1)[i]);
@@ -2441,7 +2441,7 @@ namespace SphereSegmentIntersector
// copy across from the next point in from fuseEnd2 to the openEnd2.
for(int j=fuseEnd2 + direction2;
j != openEnd2 + direction2;
j != openEnd2 + direction2;
j += direction2)
{
newline->push_back((*line2)[j]);
@@ -2470,7 +2470,7 @@ namespace SphereSegmentIntersector
_generatedLines = fusedLines;
_generatedLines.insert(_generatedLines.end(), unfusedLines.begin(), unfusedLines.end());
}
}
}
};
@@ -2555,7 +2555,7 @@ namespace SphereSegmentIntersector
{
double div = d2-d1;
if (div==0.0)
if (div==0.0)
{
edge->_intersectionType = TriangleIntersectOperator::Edge::NO_INTERSECTION;
return false;
@@ -2586,7 +2586,7 @@ namespace SphereSegmentIntersector
double d2 = _plane.distance(v2);
double div = d2-d1;
if (div==0.0)
if (div==0.0)
{
return v1;
}
@@ -2602,9 +2602,9 @@ namespace SphereSegmentIntersector
{
return _lowerOutside ? _plane.distance(v) : -_plane.distance(v) ;
}
protected:
AzimPlaneIntersector& operator = (const AzimPlaneIntersector&) { return *this; }
};
@@ -2743,9 +2743,9 @@ namespace SphereSegmentIntersector
return _lowerOutside ? computedElev-_elev : _elev-computedElev ;
}
protected:
ElevationIntersector& operator = (const ElevationIntersector&) { return *this; }
};
@@ -2875,7 +2875,7 @@ namespace SphereSegmentIntersector
protected:
RadiusIntersector& operator = (const RadiusIntersector&) { return *this; }
};
@@ -2888,14 +2888,14 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
// cast to Geometry, return empty handed if Drawable not a Geometry.
osg::Geometry* geometry = dynamic_cast<osg::Geometry*>(drawable);
if (!geometry) return SphereSegment::LineList();
// get vertices from geometry, return empty handed if a Vec3Array not present.
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray());
if (!vertices) return SphereSegment::LineList();
typedef osg::TriangleIndexFunctor<TriangleIntersectOperator> TriangleIntersectFunctor;
TriangleIntersectFunctor tif;
tif._centre = _centre;
tif._radius = _radius;
tif._azMin = _azMin;
@@ -2904,10 +2904,10 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
tif._elevMax = _elevMax;
tif.computePositionAndRegions(matrix, *vertices);
// traverse the triangles in the Geometry dedicating intersections
geometry->accept(tif);
OSG_INFO<<"_numOutside = "<<tif._numOutside<<std::endl;
OSG_INFO<<"_numInside = "<<tif._numInside<<std::endl;
OSG_INFO<<"_numIntersecting = "<<tif._numIntersecting<<std::endl;
@@ -2915,8 +2915,8 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
tif.removeDuplicateVertices();
tif.removeDuplicateTriangles();
tif.buildEdges();
RadiusIntersector radiusIntersector(tif);
AzimPlaneIntersector azMinIntersector(tif,_azMin, true);
AzimPlaneIntersector azMinEndIntersector(tif,_azMin-osg::PI*0.5, true);
@@ -2956,12 +2956,12 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
if (azimRange<=osg::PI)
{
// trim the radius and elevation intersection lines by the azimMin
// trim the radius and elevation intersection lines by the azimMin
tif.trim(radiusLines, azMinIntersector);
tif.trim(elevMinLines, azMinIntersector);
tif.trim(elevMaxLines, azMinIntersector);
// trim the radius and elevation intersection lines by the azimMax
// trim the radius and elevation intersection lines by the azimMax
tif.trim(radiusLines, azMaxIntersector);
tif.trim(elevMinLines, azMaxIntersector);
tif.trim(elevMaxLines, azMaxIntersector);
@@ -2980,10 +2980,10 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
tif.trim(elevMinLines,radiusIntersector);
tif.trim(elevMaxLines,radiusIntersector);
// trim the radius and elevation intersection lines by the elevMin
// trim the radius and elevation intersection lines by the elevMin
tif.trim(radiusLines, elevMinIntersector);
// trim the radius and elevation intersection lines by the elevMax
// trim the radius and elevation intersection lines by the elevMax
tif.trim(radiusLines, elevMaxIntersector);
// collect all lines together.
@@ -2992,7 +2992,7 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
tif._generatedLines.insert(tif._generatedLines.end(), azMaxLines.begin(), azMaxLines.end());
tif._generatedLines.insert(tif._generatedLines.end(), elevMinLines.begin(), elevMinLines.end());
tif._generatedLines.insert(tif._generatedLines.end(), elevMaxLines.begin(), elevMaxLines.end());
OSG_INFO<<"number of separate lines = "<<tif._generatedLines.size()<<std::endl;
float fuseDistance = 1.0;
@@ -3006,7 +3006,7 @@ SphereSegment::LineList SphereSegment::computeIntersection(const osg::Matrixd& m
tif.joinEnds(joinDistance, false, true);
OSG_INFO<<"number of separate lines after second join = "<<tif._generatedLines.size()<<std::endl;
return tif._generatedLines;
}
@@ -3035,7 +3035,7 @@ osg::Node* SphereSegment::computeIntersectionSubgraph(const osg::Matrixd& matrix
for(unsigned int i=0; i<tif._originalVertices.size(); ++i)
{
osg::ShapeDrawable* sd = new osg::ShapeDrawable(new osg::Sphere(tif._originalVertices[i]+tif._centre,radius));
TriangleIntersectFunctor::RegionCounter rc;
rc.add(tif._regions[i]);
@@ -3052,7 +3052,7 @@ osg::Node* SphereSegment::computeIntersectionSubgraph(const osg::Matrixd& matrix
{
sd->setColor(osg::Vec4(1.0,1.0,1.0,1.0));
}
geode->addDrawable(sd);
}
#endif

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/