diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 6bca764bf..2ba7e2793 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -308,11 +308,11 @@ unsigned int Image::getTotalSizeInBytesIncludingMipmaps() const case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): sizeOfLastMipMap = maximum(sizeOfLastMipMap, 8u); // block size of 8 - break; + break; case(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT): case(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT): sizeOfLastMipMap = maximum(sizeOfLastMipMap, 16u); // block size of 16 - break; + break; default: break; } diff --git a/src/osg/LightModel.cpp b/src/osg/LightModel.cpp index bb37ad389..ae5c8ceae 100644 --- a/src/osg/LightModel.cpp +++ b/src/osg/LightModel.cpp @@ -55,11 +55,11 @@ void LightModel::apply(State&) const { if (_colorControl==SEPARATE_SPECULAR_COLOR) { - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR); + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR); } else { - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR); + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR); } } diff --git a/src/osg/Matrixd.cpp b/src/osg/Matrixd.cpp index 83a059134..394e7960e 100644 --- a/src/osg/Matrixd.cpp +++ b/src/osg/Matrixd.cpp @@ -59,45 +59,45 @@ class MatrixdTestFixture { public: - MatrixdTestFixture(); + MatrixdTestFixture(); - void testMatrixToQuat(const osgUtx::TestContext& ctx); + void testMatrixToQuat(const osgUtx::TestContext& ctx); private: - // Some convenience variables for use in the tests - Matrixd m1_, m2_; - double l1_, l2_; + // Some convenience variables for use in the tests + Matrixd m1_, m2_; + double l1_, l2_; }; MatrixdTestFixture::MatrixdTestFixture(): - m1_(0.3583681546368404100000000000000, -0.933580347769909500000000000000, 3.006977197034146200000000000000e-011, 000000000000000, - -0.933580347769909500000000000000, -0.3583681546368404100000000000000, -1.275368738108216700000000000000e-010, 000000000000000, - 1.298419676971558500000000000000e-010, 1.763260594230249800000000000000e-011, -0.9999999999999997800000000000000, 000000000000000, - -4.134153519264493800000000000000e-005, 8.473552245044272300000000000000e-008, 0.9999996934706840700000000000000, 100000000000000.0 ), + m1_(0.3583681546368404100000000000000, -0.933580347769909500000000000000, 3.006977197034146200000000000000e-011, 000000000000000, + -0.933580347769909500000000000000, -0.3583681546368404100000000000000, -1.275368738108216700000000000000e-010, 000000000000000, + 1.298419676971558500000000000000e-010, 1.763260594230249800000000000000e-011, -0.9999999999999997800000000000000, 000000000000000, + -4.134153519264493800000000000000e-005, 8.473552245044272300000000000000e-008, 0.9999996934706840700000000000000, 100000000000000.0 ), - m2_( 0.3583681546368407400000000000000, -0.9335803477699099500000000000000, 3.007582030796253300000000000000e-011, 000000000000000, - -0.9335803477699099500000000000000, -0.3583681546368407400000000000000, -1.265511449721884600000000000000e-010, 000000000000000, - 1.289238781567697100000000000000e-010, 1.727370550828948600000000000000e-011, -1.000000000000000400000000000000, 000000000000000, - -4.134153473360120600000000000000e-005, 8.473570190103158800000000000000e-008, 0.999999693471385400000000000000, 100000000000000.0), - l1_(1), - l2_(1) + m2_( 0.3583681546368407400000000000000, -0.9335803477699099500000000000000, 3.007582030796253300000000000000e-011, 000000000000000, + -0.9335803477699099500000000000000, -0.3583681546368407400000000000000, -1.265511449721884600000000000000e-010, 000000000000000, + 1.289238781567697100000000000000e-010, 1.727370550828948600000000000000e-011, -1.000000000000000400000000000000, 000000000000000, + -4.134153473360120600000000000000e-005, 8.473570190103158800000000000000e-008, 0.999999693471385400000000000000, 100000000000000.0), + l1_(1), + l2_(1) { } void MatrixdTestFixture::testMatrixToQuat(const osgUtx::TestContext&) { - Quat q1,q2; - q1.set(m1_); - q2.set(m2_); - OSGUTX_TEST_F( q1.length() == l1_ ) - OSGUTX_TEST_F( q2.length() == l2_ ) + Quat q1,q2; + q1.set(m1_); + q2.set(m2_); + OSGUTX_TEST_F( q1.length() == l1_ ) + OSGUTX_TEST_F( q2.length() == l2_ ) } OSGUTX_BEGIN_TESTSUITE(Matrixd) - OSGUTX_ADD_TESTCASE(MatrixdTestFixture, testMatrixToQuat) + OSGUTX_ADD_TESTCASE(MatrixdTestFixture, testMatrixToQuat) OSGUTX_END_TESTSUITE OSGUTX_AUTOREGISTER_TESTSUITE_AT(Matrixd, root.osg) diff --git a/src/osg/Shape.cpp b/src/osg/Shape.cpp index 3ff2c8fd2..36b9c58af 100644 --- a/src/osg/Shape.cpp +++ b/src/osg/Shape.cpp @@ -28,7 +28,7 @@ void HeightField::allocate(unsigned int numColumns,unsigned int numRows) { if (_columns!=numColumns || _rows!=numRows) { - _heights.resize(numColumns*numRows); + _heights.resize(numColumns*numRows); } _columns=numColumns; _rows=numRows; @@ -40,29 +40,29 @@ Vec3 HeightField::getNormal(unsigned int c,unsigned int r) const float dz_dx; if (c==0) { - dz_dx = (getHeight(c+1,r)-getHeight(c,r))/getXInterval(); + dz_dx = (getHeight(c+1,r)-getHeight(c,r))/getXInterval(); } else if (c==getNumColumns()-1) { - dz_dx = (getHeight(c,r)-getHeight(c-1,r))/getXInterval(); + dz_dx = (getHeight(c,r)-getHeight(c-1,r))/getXInterval(); } else // assume 0getCreateFrontFace() : true; - bool drawBackFace = _hints ? _hints->getCreateBackFace() : false; + glTranslatef(sphere.getCenter().x(),sphere.getCenter().y(),sphere.getCenter().z()); + + bool drawFrontFace = _hints ? _hints->getCreateFrontFace() : true; + bool drawBackFace = _hints ? _hints->getCreateBackFace() : false; + + unsigned int numSegments = 40; + unsigned int numRows = 20; + float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); + if (ratio > 0.0f && ratio != 1.0f) { + numRows = (unsigned int) (numRows * ratio); + if (numRows < MIN_NUM_ROWS) + numRows = MIN_NUM_ROWS; + numSegments = (unsigned int) (numSegments * ratio); + if (numSegments < MIN_NUM_SEGMENTS) + numSegments = MIN_NUM_SEGMENTS; + } + + float lDelta = osg::PI/(float)numRows; + float vDelta = 1.0f/(float)numRows; + + float angleDelta = osg::PI*2.0f/(float)numSegments; + float texCoordHorzDelta = 1.0f/(float)numSegments; + + if (drawBackFace) + { + float lBase=-osg::PI*0.5f; + float rBase=0.0f; + float zBase=-sphere.getRadius(); + float vBase=0.0f; + float nzBase=-1.0f; + float nRatioBase=0.0f; + + for(unsigned int rowi=0; rowigetDetailRatio() : 1.0f); - if (ratio > 0.0f && ratio != 1.0f) { - numRows = (unsigned int) (numRows * ratio); - if (numRows < MIN_NUM_ROWS) - numRows = MIN_NUM_ROWS; - numSegments = (unsigned int) (numSegments * ratio); - if (numSegments < MIN_NUM_SEGMENTS) - numSegments = MIN_NUM_SEGMENTS; } - - float lDelta = osg::PI/(float)numRows; - float vDelta = 1.0f/(float)numRows; - - float angleDelta = osg::PI*2.0f/(float)numSegments; - float texCoordHorzDelta = 1.0f/(float)numSegments; - - if (drawBackFace) - { - float lBase=-osg::PI*0.5f; - float rBase=0.0f; - float zBase=-sphere.getRadius(); - float vBase=0.0f; - float nzBase=-1.0f; - float nRatioBase=0.0f; - - for(unsigned int rowi=0; rowigetCreateBody() : true); - bool createBottom = (_hints ? _hints->getCreateBottom() : true); + // evaluate hints + bool createBody = (_hints ? _hints->getCreateBody() : true); + bool createBottom = (_hints ? _hints->getCreateBottom() : true); - unsigned int numSegments = 40; - unsigned int numRows = 10; - float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); - if (ratio > 0.0f && ratio != 1.0f) { - numRows = (unsigned int) (numRows * ratio); - if (numRows < MIN_NUM_ROWS) - numRows = MIN_NUM_ROWS; - numSegments = (unsigned int) (numSegments * ratio); - if (numSegments < MIN_NUM_SEGMENTS) - numSegments = MIN_NUM_SEGMENTS; + unsigned int numSegments = 40; + unsigned int numRows = 10; + float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); + if (ratio > 0.0f && ratio != 1.0f) { + numRows = (unsigned int) (numRows * ratio); + if (numRows < MIN_NUM_ROWS) + numRows = MIN_NUM_ROWS; + numSegments = (unsigned int) (numSegments * ratio); + if (numSegments < MIN_NUM_SEGMENTS) + numSegments = MIN_NUM_SEGMENTS; + } + + float r = cone.getRadius(); + float h = cone.getHeight(); + + float normalz = r/(sqrtf(r*r+h*h)); + float normalRatio = 1.0f/(sqrtf(1.0f+normalz*normalz)); + normalz *= normalRatio; + + float angleDelta = 2.0f*osg::PI/(float)numSegments; + float texCoordHorzDelta = 1.0/(float)numSegments; + float texCoordRowDelta = 1.0/(float)numRows; + float hDelta = cone.getHeight()/(float)numRows; + float rDelta = cone.getRadius()/(float)numRows; + + float topz=cone.getHeight()+cone.getBaseOffset(); + float topr=0.0f; + float topv=1.0f; + float basez=topz-hDelta; + float baser=rDelta; + float basev=topv-texCoordRowDelta; + float angle; + float texCoord; + + if (createBody) { + for(unsigned int rowi=0; rowigetCreateBody() : true); - bool createTop = (_hints ? _hints->getCreateTop() : true); - bool createBottom = (_hints ? _hints->getCreateBottom() : true); + // evaluate hints + bool createBody = (_hints ? _hints->getCreateBody() : true); + bool createTop = (_hints ? _hints->getCreateTop() : true); + bool createBottom = (_hints ? _hints->getCreateBottom() : true); - unsigned int numSegments = 40; - float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); - if (ratio > 0.0f && ratio != 1.0f) { - numSegments = (unsigned int) (numSegments * ratio); - if (numSegments < MIN_NUM_SEGMENTS) - numSegments = MIN_NUM_SEGMENTS; - } - + unsigned int numSegments = 40; + float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); + if (ratio > 0.0f && ratio != 1.0f) { + numSegments = (unsigned int) (numSegments * ratio); + if (numSegments < MIN_NUM_SEGMENTS) + numSegments = MIN_NUM_SEGMENTS; + } - // cylinder body - if (createBody) - drawCylinderBody(numSegments, cylinder.getRadius(), cylinder.getHeight()); - float angleDelta = 2.0f*osg::PI/(float)numSegments; - float texCoordDelta = 1.0f/(float)numSegments; - - float r = cylinder.getRadius(); - float h = cylinder.getHeight(); - - float basez = -h*0.5f; - float topz = h*0.5f; - - float angle = 0.0f; - float texCoord = 0.0f; + // cylinder body + if (createBody) + drawCylinderBody(numSegments, cylinder.getRadius(), cylinder.getHeight()); - // cylinder top - if (createTop) { - glBegin(GL_TRIANGLE_FAN); - - glNormal3f(0.0f,0.0f,1.0f); - glTexCoord2f(0.5f,0.5f); - glVertex3f(0.0f,0.0f,topz); + float angleDelta = 2.0f*osg::PI/(float)numSegments; + float texCoordDelta = 1.0f/(float)numSegments; - angle = 0.0f; - texCoord = 0.0f; - for(unsigned int topi=0; - topigetCreateBody() : true); - bool createTop = (_hints ? _hints->getCreateTop() : true); - bool createBottom = (_hints ? _hints->getCreateBottom() : true); + // evaluate hints + bool createBody = (_hints ? _hints->getCreateBody() : true); + bool createTop = (_hints ? _hints->getCreateTop() : true); + bool createBottom = (_hints ? _hints->getCreateBottom() : true); - unsigned int numSegments = 40; - unsigned int numRows = 20; - float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); - if (ratio > 0.0f && ratio != 1.0f) { - numSegments = (unsigned int) (numSegments * ratio); - if (numSegments < MIN_NUM_SEGMENTS) - numSegments = MIN_NUM_SEGMENTS; - numRows = (unsigned int) (numRows * ratio); - if (numRows < MIN_NUM_ROWS) - numRows = MIN_NUM_ROWS; - } - + unsigned int numSegments = 40; + unsigned int numRows = 20; + float ratio = (_hints ? _hints->getDetailRatio() : 1.0f); + if (ratio > 0.0f && ratio != 1.0f) { + numSegments = (unsigned int) (numSegments * ratio); + if (numSegments < MIN_NUM_SEGMENTS) + numSegments = MIN_NUM_SEGMENTS; + numRows = (unsigned int) (numRows * ratio); + if (numRows < MIN_NUM_ROWS) + numRows = MIN_NUM_ROWS; + } - // capsule cylindrical body - if (createBody) - drawCylinderBody(numSegments, capsule.getRadius(), capsule.getHeight()); - // capsule top cap - if (createTop) - drawHalfSphere(numSegments, numRows, capsule.getRadius(), SphereTopHalf, capsule.getHeight()/2.0f); + // capsule cylindrical body + if (createBody) + drawCylinderBody(numSegments, capsule.getRadius(), capsule.getHeight()); - // capsule bottom cap - if (createBottom) - drawHalfSphere(numSegments, numRows, capsule.getRadius(), SphereBottomHalf, -capsule.getHeight()/2.0f); + // capsule top cap + if (createTop) + drawHalfSphere(numSegments, numRows, capsule.getRadius(), SphereTopHalf, capsule.getHeight()/2.0f); + + // capsule bottom cap + if (createBottom) + drawHalfSphere(numSegments, numRows, capsule.getRadius(), SphereBottomHalf, -capsule.getHeight()/2.0f); glPopMatrix(); } @@ -839,25 +840,25 @@ void DrawShapeVisitor::apply(const TriangleMesh& mesh) if (vertices && indices) { - glBegin(GL_TRIANGLES); + glBegin(GL_TRIANGLES); - for(unsigned int i=0;i+2getNumElements();i+=3) - { - const osg::Vec3& v1=(*vertices)[indices->index(i)]; - const osg::Vec3& v2=(*vertices)[indices->index(i+1)]; - const osg::Vec3& v3=(*vertices)[indices->index(i+2)]; - Vec3 normal = (v2-v1)^(v3-v2); - normal.normalize(); + for(unsigned int i=0;i+2getNumElements();i+=3) + { + const osg::Vec3& v1=(*vertices)[indices->index(i)]; + const osg::Vec3& v2=(*vertices)[indices->index(i+1)]; + const osg::Vec3& v3=(*vertices)[indices->index(i+2)]; + Vec3 normal = (v2-v1)^(v3-v2); + normal.normalize(); - glNormal3fv(normal.ptr()); - glVertex3fv(v1.ptr()); - glVertex3fv(v2.ptr()); - glVertex3fv(v3.ptr()); + glNormal3fv(normal.ptr()); + glVertex3fv(v1.ptr()); + glVertex3fv(v2.ptr()); + glVertex3fv(v3.ptr()); - } + } - glEnd(); - } + glEnd(); + } } void DrawShapeVisitor::apply(const ConvexHull& hull) @@ -871,147 +872,147 @@ void DrawShapeVisitor::apply(const HeightField& field) glPushMatrix(); - glTranslatef(field.getOrigin().x(),field.getOrigin().y(),field.getOrigin().z()); - + glTranslatef(field.getOrigin().x(),field.getOrigin().y(),field.getOrigin().z()); - if (!field.zeroRotation()) - { - Matrix rotation(field.computeRotationMatrix()); - glMultMatrix(rotation.ptr()); - } - - float dx = field.getXInterval(); - float dy = field.getYInterval(); - float du = 1.0f/((float)field.getNumColumns()-1.0f); - float dv = 1.0f/((float)field.getNumRows()-1.0f); + if (!field.zeroRotation()) + { + Matrix rotation(field.computeRotationMatrix()); + glMultMatrix(rotation.ptr()); + } - float vBase = 0.0f; - - Vec3 vertTop; - Vec3 normTop; + float dx = field.getXInterval(); + float dy = field.getYInterval(); - Vec3 vertBase; - Vec3 normBase; + float du = 1.0f/((float)field.getNumColumns()-1.0f); + float dv = 1.0f/((float)field.getNumRows()-1.0f); - if (field.getSkirtHeight()!=0.0f) + float vBase = 0.0f; + + Vec3 vertTop; + Vec3 normTop; + + Vec3 vertBase; + Vec3 normBase; + + if (field.getSkirtHeight()!=0.0f) + { + glBegin(GL_QUAD_STRIP); + + float u = 0.0f; + + // draw bottom skirt + unsigned int col; + vertTop.y() = 0.0f; + for(col=0;colaccept(*this); + group.getChild(i)->accept(*this); } } @@ -1038,22 +1039,22 @@ class ComputeBoundShapeVisitor : public ConstShapeVisitor { public: - ComputeBoundShapeVisitor(BoundingBox& bb):_bb(bb) {} - - virtual void apply(const Sphere&); - virtual void apply(const Box&); - virtual void apply(const Cone&); - virtual void apply(const Cylinder&); - virtual void apply(const Capsule&); - virtual void apply(const InfinitePlane&); + ComputeBoundShapeVisitor(BoundingBox& bb):_bb(bb) {} - virtual void apply(const TriangleMesh&); - virtual void apply(const ConvexHull&); - virtual void apply(const HeightField&); + virtual void apply(const Sphere&); + virtual void apply(const Box&); + virtual void apply(const Cone&); + virtual void apply(const Cylinder&); + virtual void apply(const Capsule&); + virtual void apply(const InfinitePlane&); - virtual void apply(const CompositeShape&); - - BoundingBox& _bb; + virtual void apply(const TriangleMesh&); + virtual void apply(const ConvexHull&); + virtual void apply(const HeightField&); + + virtual void apply(const CompositeShape&); + + BoundingBox& _bb; }; @@ -1068,35 +1069,35 @@ void ComputeBoundShapeVisitor::apply(const Box& box) { if (box.zeroRotation()) { - _bb.expandBy(box.getCenter()-box.getHalfLengths()); - _bb.expandBy(box.getCenter()+box.getHalfLengths()); + _bb.expandBy(box.getCenter()-box.getHalfLengths()); + _bb.expandBy(box.getCenter()+box.getHalfLengths()); } else { - float x = box.getHalfLengths().x(); - float y = box.getHalfLengths().y(); - float z = box.getHalfLengths().z(); + float x = box.getHalfLengths().x(); + float y = box.getHalfLengths().y(); + float z = box.getHalfLengths().z(); - Vec3 base_1(Vec3(-x,-y,-z)); - Vec3 base_2(Vec3(x,-y,-z)); - Vec3 base_3(Vec3(x,y,-z)); - Vec3 base_4(Vec3(-x,y,-z)); - - Vec3 top_1(Vec3(-x,-y,z)); - Vec3 top_2(Vec3(x,-y,z)); - Vec3 top_3(Vec3(x,y,z)); - Vec3 top_4(Vec3(-x,y,z)); + Vec3 base_1(Vec3(-x,-y,-z)); + Vec3 base_2(Vec3(x,-y,-z)); + Vec3 base_3(Vec3(x,y,-z)); + Vec3 base_4(Vec3(-x,y,-z)); + + Vec3 top_1(Vec3(-x,-y,z)); + Vec3 top_2(Vec3(x,-y,z)); + Vec3 top_3(Vec3(x,y,z)); + Vec3 top_4(Vec3(-x,y,z)); Matrix matrix = box.computeRotationMatrix(); - _bb.expandBy(box.getCenter()+base_1*matrix); - _bb.expandBy(box.getCenter()+base_2*matrix); - _bb.expandBy(box.getCenter()+base_3*matrix); - _bb.expandBy(box.getCenter()+base_4*matrix); + _bb.expandBy(box.getCenter()+base_1*matrix); + _bb.expandBy(box.getCenter()+base_2*matrix); + _bb.expandBy(box.getCenter()+base_3*matrix); + _bb.expandBy(box.getCenter()+base_4*matrix); - _bb.expandBy(box.getCenter()+top_1*matrix); - _bb.expandBy(box.getCenter()+top_2*matrix); - _bb.expandBy(box.getCenter()+top_3*matrix); - _bb.expandBy(box.getCenter()+top_4*matrix); + _bb.expandBy(box.getCenter()+top_1*matrix); + _bb.expandBy(box.getCenter()+top_2*matrix); + _bb.expandBy(box.getCenter()+top_3*matrix); + _bb.expandBy(box.getCenter()+top_4*matrix); } } @@ -1104,24 +1105,24 @@ void ComputeBoundShapeVisitor::apply(const Cone& cone) { if (cone.zeroRotation()) { - _bb.expandBy(cone.getCenter()+Vec3(-cone.getRadius(),-cone.getRadius(),cone.getBaseOffset())); - _bb.expandBy(cone.getCenter()+Vec3(cone.getRadius(),cone.getRadius(),cone.getHeight()+cone.getBaseOffset())); - + _bb.expandBy(cone.getCenter()+Vec3(-cone.getRadius(),-cone.getRadius(),cone.getBaseOffset())); + _bb.expandBy(cone.getCenter()+Vec3(cone.getRadius(),cone.getRadius(),cone.getHeight()+cone.getBaseOffset())); + } else { - Vec3 top(Vec3(cone.getRadius(),cone.getRadius(),cone.getHeight()+cone.getBaseOffset())); - Vec3 base_1(Vec3(-cone.getRadius(),-cone.getRadius(),cone.getBaseOffset())); - Vec3 base_2(Vec3(cone.getRadius(),-cone.getRadius(),cone.getBaseOffset())); - Vec3 base_3(Vec3(cone.getRadius(),cone.getRadius(),cone.getBaseOffset())); - Vec3 base_4(Vec3(-cone.getRadius(),cone.getRadius(),cone.getBaseOffset())); - + Vec3 top(Vec3(cone.getRadius(),cone.getRadius(),cone.getHeight()+cone.getBaseOffset())); + Vec3 base_1(Vec3(-cone.getRadius(),-cone.getRadius(),cone.getBaseOffset())); + Vec3 base_2(Vec3(cone.getRadius(),-cone.getRadius(),cone.getBaseOffset())); + Vec3 base_3(Vec3(cone.getRadius(),cone.getRadius(),cone.getBaseOffset())); + Vec3 base_4(Vec3(-cone.getRadius(),cone.getRadius(),cone.getBaseOffset())); + Matrix matrix = cone.computeRotationMatrix(); - _bb.expandBy(cone.getCenter()+base_1*matrix); - _bb.expandBy(cone.getCenter()+base_2*matrix); - _bb.expandBy(cone.getCenter()+base_3*matrix); - _bb.expandBy(cone.getCenter()+base_4*matrix); - _bb.expandBy(cone.getCenter()+top*matrix); + _bb.expandBy(cone.getCenter()+base_1*matrix); + _bb.expandBy(cone.getCenter()+base_2*matrix); + _bb.expandBy(cone.getCenter()+base_3*matrix); + _bb.expandBy(cone.getCenter()+base_4*matrix); + _bb.expandBy(cone.getCenter()+top*matrix); } } @@ -1130,35 +1131,35 @@ void ComputeBoundShapeVisitor::apply(const Cylinder& cylinder) if (cylinder.zeroRotation()) { Vec3 halfLengths(cylinder.getRadius(),cylinder.getRadius(),cylinder.getHeight()*0.5f); - _bb.expandBy(cylinder.getCenter()-halfLengths); - _bb.expandBy(cylinder.getCenter()+halfLengths); + _bb.expandBy(cylinder.getCenter()-halfLengths); + _bb.expandBy(cylinder.getCenter()+halfLengths); } else { - float r = cylinder.getRadius(); - float z = cylinder.getHeight()*0.5f; + float r = cylinder.getRadius(); + float z = cylinder.getHeight()*0.5f; - Vec3 base_1(Vec3(-r,-r,-z)); - Vec3 base_2(Vec3(r,-r,-z)); - Vec3 base_3(Vec3(r,r,-z)); - Vec3 base_4(Vec3(-r,r,-z)); - - Vec3 top_1(Vec3(-r,-r,z)); - Vec3 top_2(Vec3(r,-r,z)); - Vec3 top_3(Vec3(r,r,z)); - Vec3 top_4(Vec3(-r,r,z)); + Vec3 base_1(Vec3(-r,-r,-z)); + Vec3 base_2(Vec3(r,-r,-z)); + Vec3 base_3(Vec3(r,r,-z)); + Vec3 base_4(Vec3(-r,r,-z)); + + Vec3 top_1(Vec3(-r,-r,z)); + Vec3 top_2(Vec3(r,-r,z)); + Vec3 top_3(Vec3(r,r,z)); + Vec3 top_4(Vec3(-r,r,z)); Matrix matrix = cylinder.computeRotationMatrix(); - _bb.expandBy(cylinder.getCenter()+base_1*matrix); - _bb.expandBy(cylinder.getCenter()+base_2*matrix); - _bb.expandBy(cylinder.getCenter()+base_3*matrix); - _bb.expandBy(cylinder.getCenter()+base_4*matrix); + _bb.expandBy(cylinder.getCenter()+base_1*matrix); + _bb.expandBy(cylinder.getCenter()+base_2*matrix); + _bb.expandBy(cylinder.getCenter()+base_3*matrix); + _bb.expandBy(cylinder.getCenter()+base_4*matrix); - _bb.expandBy(cylinder.getCenter()+top_1*matrix); - _bb.expandBy(cylinder.getCenter()+top_2*matrix); - _bb.expandBy(cylinder.getCenter()+top_3*matrix); - _bb.expandBy(cylinder.getCenter()+top_4*matrix); + _bb.expandBy(cylinder.getCenter()+top_1*matrix); + _bb.expandBy(cylinder.getCenter()+top_2*matrix); + _bb.expandBy(cylinder.getCenter()+top_3*matrix); + _bb.expandBy(cylinder.getCenter()+top_4*matrix); } } @@ -1167,35 +1168,35 @@ void ComputeBoundShapeVisitor::apply(const Capsule& capsule) if (capsule.zeroRotation()) { Vec3 halfLengths(capsule.getRadius(),capsule.getRadius(),capsule.getHeight()*0.5f + capsule.getRadius()); - _bb.expandBy(capsule.getCenter()-halfLengths); - _bb.expandBy(capsule.getCenter()+halfLengths); + _bb.expandBy(capsule.getCenter()-halfLengths); + _bb.expandBy(capsule.getCenter()+halfLengths); } else { - float r = capsule.getRadius(); - float z = capsule.getHeight()*0.5f + capsule.getRadius(); + float r = capsule.getRadius(); + float z = capsule.getHeight()*0.5f + capsule.getRadius(); - Vec3 base_1(Vec3(-r,-r,-z)); - Vec3 base_2(Vec3(r,-r,-z)); - Vec3 base_3(Vec3(r,r,-z)); - Vec3 base_4(Vec3(-r,r,-z)); - - Vec3 top_1(Vec3(-r,-r,z)); - Vec3 top_2(Vec3(r,-r,z)); - Vec3 top_3(Vec3(r,r,z)); - Vec3 top_4(Vec3(-r,r,z)); + Vec3 base_1(Vec3(-r,-r,-z)); + Vec3 base_2(Vec3(r,-r,-z)); + Vec3 base_3(Vec3(r,r,-z)); + Vec3 base_4(Vec3(-r,r,-z)); + + Vec3 top_1(Vec3(-r,-r,z)); + Vec3 top_2(Vec3(r,-r,z)); + Vec3 top_3(Vec3(r,r,z)); + Vec3 top_4(Vec3(-r,r,z)); Matrix matrix = capsule.computeRotationMatrix(); - _bb.expandBy(capsule.getCenter()+base_1*matrix); - _bb.expandBy(capsule.getCenter()+base_2*matrix); - _bb.expandBy(capsule.getCenter()+base_3*matrix); - _bb.expandBy(capsule.getCenter()+base_4*matrix); + _bb.expandBy(capsule.getCenter()+base_1*matrix); + _bb.expandBy(capsule.getCenter()+base_2*matrix); + _bb.expandBy(capsule.getCenter()+base_3*matrix); + _bb.expandBy(capsule.getCenter()+base_4*matrix); - _bb.expandBy(capsule.getCenter()+top_1*matrix); - _bb.expandBy(capsule.getCenter()+top_2*matrix); - _bb.expandBy(capsule.getCenter()+top_3*matrix); - _bb.expandBy(capsule.getCenter()+top_4*matrix); + _bb.expandBy(capsule.getCenter()+top_1*matrix); + _bb.expandBy(capsule.getCenter()+top_2*matrix); + _bb.expandBy(capsule.getCenter()+top_3*matrix); + _bb.expandBy(capsule.getCenter()+top_4*matrix); } } @@ -1209,14 +1210,14 @@ void ComputeBoundShapeVisitor::apply(const TriangleMesh& mesh) const Vec3Array* vertices = mesh.getVertices(); const IndexArray* indices = mesh.getIndices(); - if (vertices && indices) - { - for(unsigned int i=0;igetNumElements();++i) - { - const osg::Vec3& v=(*vertices)[indices->index(i)]; - _bb.expandBy(v); - } - } + if (vertices && indices) + { + for(unsigned int i=0;igetNumElements();++i) + { + const osg::Vec3& v=(*vertices)[indices->index(i)]; + _bb.expandBy(v); + } + } } void ComputeBoundShapeVisitor::apply(const ConvexHull& hull) @@ -1226,20 +1227,17 @@ void ComputeBoundShapeVisitor::apply(const ConvexHull& hull) void ComputeBoundShapeVisitor::apply(const HeightField& field) { - - - float zMin=FLT_MAX; float zMax=-FLT_MAX; for(unsigned int row=0;rowzMax) zMax = z; - } + for(unsigned int col=0;colzMax) zMax = z; + } } if (zMin>zMax) @@ -1248,37 +1246,37 @@ void ComputeBoundShapeVisitor::apply(const HeightField& field) return; } - + if (field.zeroRotation()) { - _bb.expandBy(field.getOrigin()+osg::Vec3(0.0f,0.0f,zMin)); - _bb.expandBy(field.getOrigin()+osg::Vec3(field.getXInterval()*(field.getNumColumns()-1),field.getYInterval()*(field.getNumRows()-1),zMax)); + _bb.expandBy(field.getOrigin()+osg::Vec3(0.0f,0.0f,zMin)); + _bb.expandBy(field.getOrigin()+osg::Vec3(field.getXInterval()*(field.getNumColumns()-1),field.getYInterval()*(field.getNumRows()-1),zMax)); } else { - float x = field.getXInterval()*(field.getNumColumns()-1); - float y = field.getYInterval()*(field.getNumRows()-1); + float x = field.getXInterval()*(field.getNumColumns()-1); + float y = field.getYInterval()*(field.getNumRows()-1); - Vec3 base_1(Vec3(0,0,zMin)); - Vec3 base_2(Vec3(x,0,zMin)); - Vec3 base_3(Vec3(x,y,zMin)); - Vec3 base_4(Vec3(0,y,zMin)); + Vec3 base_1(Vec3(0,0,zMin)); + Vec3 base_2(Vec3(x,0,zMin)); + Vec3 base_3(Vec3(x,y,zMin)); + Vec3 base_4(Vec3(0,y,zMin)); - Vec3 top_1(Vec3(0,0,zMax)); - Vec3 top_2(Vec3(x,0,zMax)); - Vec3 top_3(Vec3(x,y,zMax)); - Vec3 top_4(Vec3(0,y,zMax)); + Vec3 top_1(Vec3(0,0,zMax)); + Vec3 top_2(Vec3(x,0,zMax)); + Vec3 top_3(Vec3(x,y,zMax)); + Vec3 top_4(Vec3(0,y,zMax)); Matrix matrix = field.computeRotationMatrix(); - _bb.expandBy(field.getOrigin()+base_1*matrix); - _bb.expandBy(field.getOrigin()+base_2*matrix); - _bb.expandBy(field.getOrigin()+base_3*matrix); - _bb.expandBy(field.getOrigin()+base_4*matrix); + _bb.expandBy(field.getOrigin()+base_1*matrix); + _bb.expandBy(field.getOrigin()+base_2*matrix); + _bb.expandBy(field.getOrigin()+base_3*matrix); + _bb.expandBy(field.getOrigin()+base_4*matrix); - _bb.expandBy(field.getOrigin()+top_1*matrix); - _bb.expandBy(field.getOrigin()+top_2*matrix); - _bb.expandBy(field.getOrigin()+top_3*matrix); - _bb.expandBy(field.getOrigin()+top_4*matrix); + _bb.expandBy(field.getOrigin()+top_1*matrix); + _bb.expandBy(field.getOrigin()+top_2*matrix); + _bb.expandBy(field.getOrigin()+top_3*matrix); + _bb.expandBy(field.getOrigin()+top_4*matrix); } } @@ -1287,7 +1285,7 @@ void ComputeBoundShapeVisitor::apply(const CompositeShape& group) { for(unsigned int i=0;iaccept(*this); + group.getChild(i)->accept(*this); } } @@ -1303,25 +1301,25 @@ class PrimitiveShapeVisitor : public ConstShapeVisitor { public: - PrimitiveShapeVisitor(PrimitiveFunctor& functor,const TessellationHints* hints): + PrimitiveShapeVisitor(PrimitiveFunctor& functor,const TessellationHints* hints): _functor(functor), - _hints(hints) {} - - virtual void apply(const Sphere&); - virtual void apply(const Box&); - virtual void apply(const Cone&); - virtual void apply(const Cylinder&); - virtual void apply(const Capsule&); - virtual void apply(const InfinitePlane&); + _hints(hints) {} - virtual void apply(const TriangleMesh&); - virtual void apply(const ConvexHull&); - virtual void apply(const HeightField&); + virtual void apply(const Sphere&); + virtual void apply(const Box&); + virtual void apply(const Cone&); + virtual void apply(const Cylinder&); + virtual void apply(const Capsule&); + virtual void apply(const InfinitePlane&); + + virtual void apply(const TriangleMesh&); + virtual void apply(const ConvexHull&); + virtual void apply(const HeightField&); + + virtual void apply(const CompositeShape&); - virtual void apply(const CompositeShape&); - PrimitiveFunctor& _functor; - const TessellationHints* _hints; + const TessellationHints* _hints; }; @@ -1329,7 +1327,7 @@ class PrimitiveShapeVisitor : public ConstShapeVisitor void PrimitiveShapeVisitor::apply(const Sphere& sphere) { - + float tx = sphere.getCenter().x(); float ty = sphere.getCenter().y(); float tz = sphere.getCenter().z(); @@ -1349,45 +1347,45 @@ void PrimitiveShapeVisitor::apply(const Sphere& sphere) float vBase=0.0f; for(unsigned int rowi=0; - rowigetNumElements();i+=3) - { - _functor.vertex((*vertices)[indices->index(i)]); - _functor.vertex((*vertices)[indices->index(i+1)]); - _functor.vertex((*vertices)[indices->index(i+2)]); - } + for(unsigned int i=0;igetNumElements();i+=3) + { + _functor.vertex((*vertices)[indices->index(i)]); + _functor.vertex((*vertices)[indices->index(i+1)]); + _functor.vertex((*vertices)[indices->index(i+2)]); + } _functor.end(); } @@ -1706,19 +1704,19 @@ void PrimitiveShapeVisitor::apply(const HeightField& field) for(unsigned int row=0;rowaccept(*this); + group.getChild(i)->accept(*this); } } @@ -1784,9 +1782,9 @@ void ShapeDrawable::drawImplementation(State& state) const { glColor4fv(_color.ptr()); - DrawShapeVisitor dsv(state,_tessellationHints.get()); + DrawShapeVisitor dsv(state,_tessellationHints.get()); - _shape->accept(dsv); + _shape->accept(dsv); } } @@ -1799,7 +1797,7 @@ void ShapeDrawable::accept(PrimitiveFunctor& pf) const if (_shape.valid()) { PrimitiveShapeVisitor psv(pf,_tessellationHints.get()); - _shape->accept(psv); + _shape->accept(psv); } } @@ -1810,7 +1808,7 @@ BoundingBox ShapeDrawable::computeBound() const if (_shape.valid()) { ComputeBoundShapeVisitor cbsv(bbox); - _shape->accept(cbsv); + _shape->accept(cbsv); } return bbox; } diff --git a/src/osg/UnitTestFramework.cpp b/src/osg/UnitTestFramework.cpp index ee8cf68b0..03216caef 100644 --- a/src/osg/UnitTestFramework.cpp +++ b/src/osg/UnitTestFramework.cpp @@ -117,7 +117,7 @@ TestSuite* TestGraph::suite(const std::string& path, TestSuite* tsuite, bool cre } TestSuite* TestGraph::suite( - std::list::iterator it, + std::list::iterator it, std::list::iterator end, TestSuite* tsuite, bool createIfNecessary) { diff --git a/src/osg/Vec3.cpp b/src/osg/Vec3.cpp index 7bdc1dc69..25303e051 100644 --- a/src/osg/Vec3.cpp +++ b/src/osg/Vec3.cpp @@ -27,52 +27,52 @@ class Vec3TestFixture { public: - Vec3TestFixture(); + Vec3TestFixture(); - void testAddition(const osgUtx::TestContext& ctx); - void testSubtraction(const osgUtx::TestContext& ctx); - void testScalarMultiplication(const osgUtx::TestContext& ctx); - void testDotProduct(const osgUtx::TestContext& ctx); + void testAddition(const osgUtx::TestContext& ctx); + void testSubtraction(const osgUtx::TestContext& ctx); + void testScalarMultiplication(const osgUtx::TestContext& ctx); + void testDotProduct(const osgUtx::TestContext& ctx); private: - // Some convenience variables for use in the tests - Vec3 v1_, v2_, v3_; + // Some convenience variables for use in the tests + Vec3 v1_, v2_, v3_; }; Vec3TestFixture::Vec3TestFixture(): - v1_(1.0f, 1.0f, 1.0f), - v2_(2.0f, 2.0f, 2.0f), - v3_(3.0f, 3.0f, 3.0f) + v1_(1.0f, 1.0f, 1.0f), + v2_(2.0f, 2.0f, 2.0f), + v3_(3.0f, 3.0f, 3.0f) { } void Vec3TestFixture::testAddition(const osgUtx::TestContext&) { - OSGUTX_TEST_F( v1_ + v2_ == v3_ ) + OSGUTX_TEST_F( v1_ + v2_ == v3_ ) } void Vec3TestFixture::testSubtraction(const osgUtx::TestContext&) { - OSGUTX_TEST_F( v3_ - v1_ == v2_ ) + OSGUTX_TEST_F( v3_ - v1_ == v2_ ) } void Vec3TestFixture::testScalarMultiplication(const osgUtx::TestContext&) { - OSGUTX_TEST_F( v1_ * 3 == v3_ ) + OSGUTX_TEST_F( v1_ * 3 == v3_ ) } void Vec3TestFixture::testDotProduct(const osgUtx::TestContext&) { - + } OSGUTX_BEGIN_TESTSUITE(Vec3) - OSGUTX_ADD_TESTCASE(Vec3TestFixture, testAddition) - OSGUTX_ADD_TESTCASE(Vec3TestFixture, testSubtraction) - OSGUTX_ADD_TESTCASE(Vec3TestFixture, testScalarMultiplication) - OSGUTX_ADD_TESTCASE(Vec3TestFixture, testDotProduct) + OSGUTX_ADD_TESTCASE(Vec3TestFixture, testAddition) + OSGUTX_ADD_TESTCASE(Vec3TestFixture, testSubtraction) + OSGUTX_ADD_TESTCASE(Vec3TestFixture, testScalarMultiplication) + OSGUTX_ADD_TESTCASE(Vec3TestFixture, testDotProduct) OSGUTX_END_TESTSUITE OSGUTX_AUTOREGISTER_TESTSUITE_AT(Vec3, root.osg) diff --git a/src/osgDB/DynamicLibrary.cpp b/src/osgDB/DynamicLibrary.cpp index 7d411b0b3..6bfad164e 100644 --- a/src/osgDB/DynamicLibrary.cpp +++ b/src/osgDB/DynamicLibrary.cpp @@ -122,7 +122,7 @@ DynamicLibrary::PROC_ADDRESS DynamicLibrary::getProcAddress(const std::string& p #elif defined(__APPLE__) std::string temp("_"); NSSymbol symbol; - temp += procName; // Mac OS X prepends an underscore on function names + temp += procName; // Mac OS X prepends an underscore on function names symbol = NSLookupSymbolInModule(static_cast(_handle), temp.c_str()); return NSAddressOfSymbol(symbol); #elif defined(__hpux__) diff --git a/src/osgDB/FieldReader.cpp b/src/osgDB/FieldReader.cpp index 4e554bb48..8e89071fc 100644 --- a/src/osgDB/FieldReader.cpp +++ b/src/osgDB/FieldReader.cpp @@ -174,7 +174,7 @@ bool FieldReader::_readField(Field* fieldPtr) } _fin->ignore(1); char c; - bool escape = false; // use the escape character sequence \" to allow " to included in strings. + bool escape = false; // use the escape character sequence \" to allow " to included in strings. while (true) { ch = _fin->peek(); @@ -183,34 +183,34 @@ bool FieldReader::_readField(Field* fieldPtr) _eof = true; return fieldPtr && fieldPtr->getNoCharacters()!=0; } - c = ch; - if (ch=='\\' && !escape) - { - escape = true; + c = ch; + if (ch=='\\' && !escape) + { + escape = true; _fin->ignore(1); - } + } else if (ch=='"') { - if (escape) - { - escape = false; - _fin->get(c); - if (fieldPtr) fieldPtr->addChar(c); - } - else - { - _fin->ignore(1); - //return fieldPtr && fieldPtr->getNoCharacters()!=0; - return fieldPtr!=NULL; - } + if (escape) + { + escape = false; + _fin->get(c); + if (fieldPtr) fieldPtr->addChar(c); + } + else + { + _fin->ignore(1); + //return fieldPtr && fieldPtr->getNoCharacters()!=0; + return fieldPtr!=NULL; + } } else { - if (escape) - { - escape = false; + if (escape) + { + escape = false; if (fieldPtr) fieldPtr->addChar('\\'); - } + } _fin->get(c); if (fieldPtr) fieldPtr->addChar(c); } @@ -225,7 +225,7 @@ bool FieldReader::_readField(Field* fieldPtr) } _fin->ignore(1); char c; - bool escape = false; // use the escape character sequence \' to allow ' to included in strings. + bool escape = false; // use the escape character sequence \' to allow ' to included in strings. while (true) { ch = _fin->peek(); @@ -235,33 +235,33 @@ bool FieldReader::_readField(Field* fieldPtr) return fieldPtr && fieldPtr->getNoCharacters()!=0; } c = ch; - if (ch=='\\' && !escape) - { - escape = true; + if (ch=='\\' && !escape) + { + escape = true; _fin->ignore(1); - } + } else if (ch=='\'') { - if (escape) - { - escape = false; - _fin->get(c); - if (fieldPtr) fieldPtr->addChar(c); - } - else - { - _fin->ignore(1); - //return fieldPtr && fieldPtr->getNoCharacters()!=0; - return fieldPtr!=NULL; - } + if (escape) + { + escape = false; + _fin->get(c); + if (fieldPtr) fieldPtr->addChar(c); + } + else + { + _fin->ignore(1); + //return fieldPtr && fieldPtr->getNoCharacters()!=0; + return fieldPtr!=NULL; + } } else { - if (escape) - { - escape = false; + if (escape) + { + escape = false; if (fieldPtr) fieldPtr->addChar('\\'); - } + } _fin->get(c); if (fieldPtr) fieldPtr->addChar(c); } diff --git a/src/osgDB/FileNameUtils.cpp b/src/osgDB/FileNameUtils.cpp index 5dea580bf..1a0ce7988 100644 --- a/src/osgDB/FileNameUtils.cpp +++ b/src/osgDB/FileNameUtils.cpp @@ -43,7 +43,7 @@ std::string osgDB::getSimpleFileName(const std::string& fileName) if (slash1==std::string::npos) { if (slash2==std::string::npos) return fileName; - return std::string(fileName.begin()+slash2+1,fileName.end()); + return std::string(fileName.begin()+slash2+1,fileName.end()); } if (slash2==std::string::npos) return std::string(fileName.begin()+slash1+1,fileName.end()); return std::string(fileName.begin()+(slash1>slash2?slash1:slash2)+1,fileName.end()); diff --git a/src/osgDB/Output.cpp b/src/osgDB/Output.cpp index f8d2a3eac..e9c388ff7 100644 --- a/src/osgDB/Output.cpp +++ b/src/osgDB/Output.cpp @@ -92,12 +92,12 @@ std::string Output::wrapString(const std::string& str) newstring += '"'; for(unsigned int i=0;i ss = new osg::StateSet; @@ -202,13 +202,13 @@ namespace polyoffset->setUnits(1.0f); ss->setAttributeAndModes(polyoffset.get(), osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); - osg::ref_ptr program = new osg::Program; - program->addShader( new osg::Shader( osg::Shader::VERTEX, vert_source ) ); - program->addShader( new osg::Shader( osg::Shader::FRAGMENT, frag_source ) ); + osg::ref_ptr program = new osg::Program; + program->addShader( new osg::Shader( osg::Shader::VERTEX, vert_source ) ); + program->addShader( new osg::Shader( osg::Shader::FRAGMENT, frag_source ) ); ss->addUniform( new osg::Uniform("CartoonTexUnit", 0)); - ss->setAttributeAndModes( program.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON); - + ss->setAttributeAndModes( program.get(), osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON); + ss->setTextureMode(0, GL_TEXTURE_2D, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF); diff --git a/src/osgFX/Effect.cpp b/src/osgFX/Effect.cpp index c6f9fb74a..a18e9128e 100644 --- a/src/osgFX/Effect.cpp +++ b/src/osgFX/Effect.cpp @@ -11,7 +11,7 @@ using namespace osgFX; Effect::Effect() -: osg::Group(), +: osg::Group(), _enabled(true), _global_sel_tech(AUTO_DETECT), _techs_defined(false) @@ -20,7 +20,7 @@ Effect::Effect() } Effect::Effect(const Effect& copy, const osg::CopyOp& copyop) -: osg::Group(copy, copyop), +: osg::Group(copy, copyop), _enabled(copy._enabled), _global_sel_tech(copy._global_sel_tech), _techs_defined(false) @@ -30,49 +30,49 @@ Effect::Effect(const Effect& copy, const osg::CopyOp& copyop) Effect::~Effect() { - // disable the validator for safety, so it won't try to access us - // even if it stays alive for some reason - if (_dummy_for_validation.valid()) { - osg::StateSet* ss = _dummy_for_validation->getStateSet(); - if (ss) { - Validator *validator = dynamic_cast(ss->getAttribute(Validator::VALIDATOR)); - if (validator) { - validator->disable(); - } - } - } + // disable the validator for safety, so it won't try to access us + // even if it stays alive for some reason + if (_dummy_for_validation.valid()) { + osg::StateSet* ss = _dummy_for_validation->getStateSet(); + if (ss) { + Validator *validator = dynamic_cast(ss->getAttribute(Validator::VALIDATOR)); + if (validator) { + validator->disable(); + } + } + } } void Effect::traverse(osg::NodeVisitor& nv) { - // if this effect is not enabled, then go for default traversal + // if this effect is not enabled, then go for default traversal if (!_enabled) { inherited_traverse(nv); return; } - // ensure that at least one technique is defined + // ensure that at least one technique is defined if (!_techs_defined) { // clear existing techniques _techs.clear(); - // clear technique selection indices + // clear technique selection indices _sel_tech.clear(); - // clear technique selection flags + // clear technique selection flags _tech_selected.clear(); // define new techniques _techs_defined = define_techniques(); - // check for errors, return on failure + // check for errors, return on failure if (!_techs_defined) { osg::notify(osg::WARN) << "Warning: osgFX::Effect: could not define techniques for effect " << className() << std::endl; return; } - // ensure that at least one technique has been defined + // ensure that at least one technique has been defined if (_techs.empty()) { osg::notify(osg::WARN) << "Warning: osgFX::Effect: no techniques defined for effect " << className() << std::endl; return; @@ -82,10 +82,10 @@ void Effect::traverse(osg::NodeVisitor& nv) Technique *tech = 0; // if the selection mode is set to AUTO_DETECT then we have to - // choose the active technique! - if (_global_sel_tech == AUTO_DETECT) { + // choose the active technique! + if (_global_sel_tech == AUTO_DETECT) { - // test whether at least one technique has been selected + // test whether at least one technique has been selected bool none_selected = true; for (unsigned i=0; i<_tech_selected.size(); ++i) { if (_tech_selected[i] != 0) { @@ -94,15 +94,15 @@ void Effect::traverse(osg::NodeVisitor& nv) } } - // no techniques selected, traverse a dummy node that - // contains the Validator (it will select a technique) + // no techniques selected, traverse a dummy node that + // contains the Validator (it will select a technique) if (none_selected) { _dummy_for_validation->accept(nv); } // find the highest priority technique that could be validated - // in all active rendering contexts - int max_index = -1; + // in all active rendering contexts + int max_index = -1; for (unsigned j=0; j<_sel_tech.size(); ++j) { if (_tech_selected[j] != 0) { if (_sel_tech[j] > max_index) { @@ -112,27 +112,27 @@ void Effect::traverse(osg::NodeVisitor& nv) } // found a valid technique? - if (max_index >= 0) { + if (max_index >= 0) { tech = _techs[max_index].get(); } } else { - // the active technique was selected manually + // the active technique was selected manually tech = _techs[_global_sel_tech].get(); } // if we could find an active technique, then continue with traversal, - // else go for default traversal (no effect) - if (tech) { - tech->traverse(nv, this); - } else { - if (nv.getTraversalMode() == osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { - inherited_traverse(nv); - } - } + // else go for default traversal (no effect) + if (tech) { + tech->traverse(nv, this); + } else { + if (nv.getTraversalMode() == osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) { + inherited_traverse(nv); + } + } - // wow, we're finished! :) + // wow, we're finished! :) } void Effect::build_dummy_node() diff --git a/src/osgFX/Technique.cpp b/src/osgFX/Technique.cpp index 8a9f481dc..e6e736b1d 100644 --- a/src/osgFX/Technique.cpp +++ b/src/osgFX/Technique.cpp @@ -8,15 +8,15 @@ using namespace osgFX; Technique::Technique() -: osg::Referenced() +: osg::Referenced() { } void Technique::addPass(osg::StateSet* ss) { - if (ss) { + if (ss) { _passes.push_back(ss); - ss->setRenderBinDetails(static_cast(_passes.size()), "RenderBin"); + ss->setRenderBinDetails(static_cast(_passes.size()), "RenderBin"); } } @@ -41,29 +41,29 @@ void Technique::traverse_implementation(osg::NodeVisitor& nv, Effect* fx) define_passes(); } - // special actions must be taken if the node visitor is actually a CullVisitor - osgUtil::CullVisitor *cv = dynamic_cast(&nv); + // special actions must be taken if the node visitor is actually a CullVisitor + osgUtil::CullVisitor *cv = dynamic_cast(&nv); - // traverse all passes - for (int i=0; ipushStateSet(_passes[i].get()); - } + // push the i-th pass' StateSet if necessary + if (cv) { + cv->pushStateSet(_passes[i].get()); + } - // traverse the override node if defined, otherwise - // traverse children as a Group would do - osg::Node *override = getOverrideChild(i); - if (override) { - override->accept(nv); - } else { - fx->inherited_traverse(nv); - } + // traverse the override node if defined, otherwise + // traverse children as a Group would do + osg::Node *override = getOverrideChild(i); + if (override) { + override->accept(nv); + } else { + fx->inherited_traverse(nv); + } - // pop the StateSet if necessary - if (cv) { - cv->popStateSet(); - } - } + // pop the StateSet if necessary + if (cv) { + cv->popStateSet(); + } + } } diff --git a/src/osgFX/Validator.cpp b/src/osgFX/Validator.cpp index a5aa825b7..0887c2020 100644 --- a/src/osgFX/Validator.cpp +++ b/src/osgFX/Validator.cpp @@ -7,7 +7,7 @@ using namespace osgFX; Validator::Validator() : osg::StateAttribute(), - _effect(0) + _effect(0) { } @@ -25,7 +25,7 @@ Validator::Validator(const Validator& copy, const osg::CopyOp& copyop) void Validator::compileGLObjects(osg::State& state) const { - apply(state); + apply(state); } void Validator::apply(osg::State& state) const diff --git a/src/osgParticle/ParticleSystem.cpp b/src/osgParticle/ParticleSystem.cpp index d207526a5..e4f98dd04 100644 --- a/src/osgParticle/ParticleSystem.cpp +++ b/src/osgParticle/ParticleSystem.cpp @@ -209,7 +209,7 @@ osg::BoundingBox osgParticle::ParticleSystem::computeBound() const return _def_bbox; } else { - return osg::BoundingBox(_bmin,_bmax); + return osg::BoundingBox(_bmin,_bmax); } } diff --git a/src/osgProducer/EventAdapter.cpp b/src/osgProducer/EventAdapter.cpp index 1b8f3f1f0..87deadf30 100644 --- a/src/osgProducer/EventAdapter.cpp +++ b/src/osgProducer/EventAdapter.cpp @@ -73,11 +73,11 @@ void EventAdapter::adaptMouseScroll(double time, Producer::KeyboardMouseCallback _time = time; if (sm == Producer::KeyboardMouseCallback::ScrollUp) - _eventType = SCROLLUP; + _eventType = SCROLLUP; else if (sm == Producer::KeyboardMouseCallback::ScrollDown) - _eventType = SCROLLDOWN; + _eventType = SCROLLDOWN; else - _eventType = NONE; + _eventType = NONE; copyStaticVariables(); } @@ -92,20 +92,17 @@ void EventAdapter::adaptButtonPress(double time,float x, float y, unsigned int b switch(_button) { case(0): - _s_accumulatedButtonMask = - _s_accumulatedButtonMask | LEFT_MOUSE_BUTTON; - _s_button = LEFT_MOUSE_BUTTON; - break; + _s_accumulatedButtonMask = _s_accumulatedButtonMask | LEFT_MOUSE_BUTTON; + _s_button = LEFT_MOUSE_BUTTON; + break; case(1): - _s_accumulatedButtonMask = - _s_accumulatedButtonMask | MIDDLE_MOUSE_BUTTON; - _s_button = MIDDLE_MOUSE_BUTTON; - break; + _s_accumulatedButtonMask = _s_accumulatedButtonMask | MIDDLE_MOUSE_BUTTON; + _s_button = MIDDLE_MOUSE_BUTTON; + break; case(2): - _s_accumulatedButtonMask = - _s_accumulatedButtonMask | RIGHT_MOUSE_BUTTON; - _s_button = RIGHT_MOUSE_BUTTON; - break; + _s_accumulatedButtonMask = _s_accumulatedButtonMask | RIGHT_MOUSE_BUTTON; + _s_button = RIGHT_MOUSE_BUTTON; + break; } _s_mx = x; @@ -124,20 +121,17 @@ void EventAdapter::adaptButtonRelease(double time,float x, float y, unsigned int switch(_button) { case(0): - _s_accumulatedButtonMask = - _s_accumulatedButtonMask & ~LEFT_MOUSE_BUTTON; - _s_button = LEFT_MOUSE_BUTTON; - break; + _s_accumulatedButtonMask = _s_accumulatedButtonMask & ~LEFT_MOUSE_BUTTON; + _s_button = LEFT_MOUSE_BUTTON; + break; case(1): - _s_accumulatedButtonMask = - _s_accumulatedButtonMask & ~MIDDLE_MOUSE_BUTTON; - _s_button = MIDDLE_MOUSE_BUTTON; - break; + _s_accumulatedButtonMask = _s_accumulatedButtonMask & ~MIDDLE_MOUSE_BUTTON; + _s_button = MIDDLE_MOUSE_BUTTON; + break; case(2): - _s_accumulatedButtonMask = - _s_accumulatedButtonMask & ~RIGHT_MOUSE_BUTTON; - _s_button = RIGHT_MOUSE_BUTTON; - break; + _s_accumulatedButtonMask = _s_accumulatedButtonMask & ~RIGHT_MOUSE_BUTTON; + _s_button = RIGHT_MOUSE_BUTTON; + break; } _s_mx = x; diff --git a/src/osgProducer/OsgCameraGroup.cpp b/src/osgProducer/OsgCameraGroup.cpp index f9661d53f..0803dd34d 100644 --- a/src/osgProducer/OsgCameraGroup.cpp +++ b/src/osgProducer/OsgCameraGroup.cpp @@ -134,33 +134,33 @@ class QuitImageStreamVisitor : public osg::NodeVisitor public: QuitImageStreamVisitor(): - osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} /** Simply traverse using standard NodeVisitor traverse method.*/ virtual void apply(osg::Node& node) - { - if (node.getStateSet()) - apply(*(node.getStateSet())); - - traverse(node); - } - - virtual void apply(osg::Geode& node) - { - if (node.getStateSet()) + { + if (node.getStateSet()) apply(*(node.getStateSet())); - for(unsigned int i=0;igetStateSet()) + traverse(node); + } + + virtual void apply(osg::Geode& node) + { + if (node.getStateSet()) + apply(*(node.getStateSet())); + + for(unsigned int i=0;igetStateSet()) apply(*(drawable->getStateSet())); - } - } - + } + } + void apply(osg::StateSet& stateset) - { + { for(unsigned int i=0;i(texture); if (textureRect) - { - osg::ImageStream* imageStream = dynamic_cast(textureRect->getImage()); - if (imageStream) - { - imageStream->quit(); - } - } + { + osg::ImageStream* imageStream = dynamic_cast(textureRect->getImage()); + if (imageStream) + { + imageStream->quit(); + } + } osg::Texture2D* texture2D = dynamic_cast(texture); if (texture2D) - { - osg::ImageStream* imageStream = dynamic_cast(texture2D->getImage()); - if (imageStream) - { - imageStream->quit(); - } - } + { + osg::ImageStream* imageStream = dynamic_cast(texture2D->getImage()); + if (imageStream) + { + imageStream->quit(); + } + } } - } - } + } + } }; diff --git a/src/osgProducer/Viewer.cpp b/src/osgProducer/Viewer.cpp index 834748a4c..3f0b27f41 100644 --- a/src/osgProducer/Viewer.cpp +++ b/src/osgProducer/Viewer.cpp @@ -360,8 +360,8 @@ Viewer::Viewer(osg::ArgumentParser& arguments): std::string pathfile; while (arguments.read("-p",pathfile)) { - osg::ref_ptr apm = new osgGA::AnimationPathManipulator(pathfile); - if( apm.valid() && apm->valid() ) + osg::ref_ptr apm = new osgGA::AnimationPathManipulator(pathfile); + if( apm.valid() && apm->valid() ) { unsigned int num = addCameraManipulator(apm.get()); selectCameraManipulator(num); diff --git a/src/osgSim/Impostor.cpp b/src/osgSim/Impostor.cpp index 5a8f29629..b9b941a68 100644 --- a/src/osgSim/Impostor.cpp +++ b/src/osgSim/Impostor.cpp @@ -211,8 +211,8 @@ ImpostorSprite* Impostor::createImpostorSprite(osgUtil::CullVisitor* cv) osgSim::ImpostorSpriteManager* impostorSpriteManager = dynamic_cast(cv->getUserData()); if (!impostorSpriteManager) { - impostorSpriteManager = new osgSim::ImpostorSpriteManager; - cv->setUserData(impostorSpriteManager); + impostorSpriteManager = new osgSim::ImpostorSpriteManager; + cv->setUserData(impostorSpriteManager); } diff --git a/src/osgSim/LightPoint.cpp b/src/osgSim/LightPoint.cpp index 9286b9620..37c44c49d 100644 --- a/src/osgSim/LightPoint.cpp +++ b/src/osgSim/LightPoint.cpp @@ -39,7 +39,7 @@ LightPoint::LightPoint(const osg::Vec3& position,const osg::Vec4& color): { } -LightPoint::LightPoint(bool on, +LightPoint::LightPoint(bool on, const osg::Vec3& position, const osg::Vec4& color, float intensity, diff --git a/src/osgSim/LightPointNode.cpp b/src/osgSim/LightPointNode.cpp index 94dcde974..b2d3f5a1c 100644 --- a/src/osgSim/LightPointNode.cpp +++ b/src/osgSim/LightPointNode.cpp @@ -251,14 +251,14 @@ void LightPointNode::traverse(osg::NodeVisitor& nv) ++itr) { const LightPoint& lp = *itr; - - if (!lp._on) continue; - + + if (!lp._on) continue; + const osg::Vec3& position = lp._position; - + // skip light point if it is not contianed in the view frustum. if (computeClipping && !clipvol.contains(position)) continue; - + // delta vector between eyepoint and light point. osg::Vec3 dv(eyePoint-position); @@ -282,12 +282,12 @@ void LightPointNode::traverse(osg::NodeVisitor& nv) if (lp._sector.valid()) { intensity *= (*lp._sector)(dv); - + // slip light point if it is intensity is 0.0 or negative. if (intensity<=minimumIntensity) continue; - + } - + // temporary accounting of intensity. //color *= intensity; @@ -304,13 +304,13 @@ void LightPointNode::traverse(osg::NodeVisitor& nv) color[2] *= bs[2]; color[3] *= bs[3]; } - + // if alpha value is less than the min intentsive then skip if (color[3]<=minimumIntensity) continue; float pixelSize = cv->pixelSize(position,lp._radius); -// cout << "pixelsize = "<setMode(GL_LIGHTING,osg::StateAttribute::OFF); - - //getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF); + // switch off lighting. + getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); + + //getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF); } @@ -197,7 +197,7 @@ public: Spoke():_ss(0) { - init(); + init(); osg::notify(osg::WARN)<< "Warning: unexpected call to osgSim::SphereSegment::Spoke() default constructor"<setMode(GL_LIGHTING,osg::StateAttribute::OFF); + // switch off lighting. + getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); - //getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF); + //getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0),osg::StateAttribute::OFF); } virtual osg::BoundingBox computeBound() const; @@ -400,23 +400,23 @@ void SphereSegment::Surface_drawImplementation(osg::State& /* state */) const { glColor4fv(_surfaceColor.ptr()); - bool drawBackSide = true; - bool drawFrontSide = true; + bool drawBackSide = true; + bool drawFrontSide = true; - // draw back side. - if (drawBackSide) - { + // draw back side. + if (drawBackSide) + { for(int i=0; i+1<=_density; i++) { - // Because we're drawing quad strips, we need to work out - // two azimuth values, to form each edge of the (z-vertical) - // strips - float az1 = _azMin + (i*azIncr); - float az2 = _azMin + ((i+1)*azIncr); + // Because we're drawing quad strips, we need to work out + // two azimuth values, to form each edge of the (z-vertical) + // strips + float az1 = _azMin + (i*azIncr); + float az2 = _azMin + ((i+1)*azIncr); - glBegin(GL_QUAD_STRIP); - for (int j=0; j<=_density; j++) - { + glBegin(GL_QUAD_STRIP); + for (int j=0; j<=_density; j++) + { float elev = _elevMin + (j*elevIncr); // QuadStrip Edge formed at az1 @@ -444,25 +444,25 @@ void SphereSegment::Surface_drawImplementation(osg::State& /* state */) const glVertex3f(_centre.x() + _radius*x, _centre.y() + _radius*y, _centre.z() + _radius*z); - } - glEnd(); + } + glEnd(); } - } - - // draw front side - if (drawFrontSide) - { + } + + // draw front side + if (drawFrontSide) + { for(int i=0; i+1<=_density; i++) { - // Because we're drawing quad strips, we need to work out - // two azimuth values, to form each edge of the (z-vertical) - // strips - float az1 = _azMin + (i*azIncr); - float az2 = _azMin + ((i+1)*azIncr); + // Because we're drawing quad strips, we need to work out + // two azimuth values, to form each edge of the (z-vertical) + // strips + float az1 = _azMin + (i*azIncr); + float az2 = _azMin + ((i+1)*azIncr); - glBegin(GL_QUAD_STRIP); - for (int j=0; j<=_density; j++) - { + glBegin(GL_QUAD_STRIP); + for (int j=0; j<=_density; j++) + { float elev = _elevMin + (j*elevIncr); // QuadStrip Edge formed at az1 @@ -491,10 +491,10 @@ void SphereSegment::Surface_drawImplementation(osg::State& /* state */) const glVertex3f(_centre.x() + _radius*x, _centre.y() + _radius*y, _centre.z() + _radius*z); - } - glEnd(); + } + glEnd(); } - } + } } } @@ -673,154 +673,153 @@ void SphereSegment::Side_drawImplementation(osg::State& /* state */, // ---------------------------- if(_drawMask & SIDES) { - bool drawBackSide = true; - bool drawFrontSide = true; - int start, end, delta; + bool drawBackSide = true; + bool drawFrontSide = true; + int start, end, delta; glColor4fv(_planeColor.ptr()); - // draw back side. - if (drawBackSide) - { + // draw back side. + if (drawBackSide) + { if(orientation == AZIM) // This is a plane at a given azimuth { - const float az = (boundaryAngle==MIN?_azMin:_azMax); - const float elevIncr = (_elevMax - _elevMin)/_density; + const float az = (boundaryAngle==MIN?_azMin:_azMax); + const float elevIncr = (_elevMax - _elevMin)/_density; - // Normal - osg::Vec3 normal = osg::Vec3(cos(_elevMin)*sin(az), cos(_elevMin)*cos(az), sin(_elevMin)) + // Normal + osg::Vec3 normal = osg::Vec3(cos(_elevMin)*sin(az), cos(_elevMin)*cos(az), sin(_elevMin)) ^ osg::Vec3(cos(_elevMax)*sin(az), cos(_elevMax)*cos(az), sin(_elevMax)); - if (boundaryAngle==MIN) - { - start = _density; - end = 0; - } - else - { - start = 0; - end = _density; - normal = -normal; // Make sure normals orientationint 'outwards' - } - delta = end>start?1:-1; + if (boundaryAngle==MIN) + { + start = _density; + end = 0; + } + else + { + start = 0; + end = _density; + normal = -normal; // Make sure normals orientationint 'outwards' + } + delta = end>start?1:-1; - if (drawBackSide) - { - // Tri fan - glNormal3f(-normal.x(),-normal.y(),-normal.z()); - glBegin(GL_TRIANGLE_FAN); - glVertex3fv(_centre.ptr()); - for (int j=start; j!=end+delta; j+=delta) - { - float elev = _elevMin + (j*elevIncr); - glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), - _centre.y() + _radius*cos(elev)*cos(az), - _centre.z() + _radius*sin(elev)); - } - glEnd(); - } - - if (boundaryAngle==MIN) - { - start = 0; - end = _density; - } - else - { - start = _density; - end = 0; - } - delta = end>start?1:-1; + if (drawBackSide) + { + // Tri fan + glNormal3f(-normal.x(),-normal.y(),-normal.z()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(_centre.ptr()); + for (int j=start; j!=end+delta; j+=delta) + { + float elev = _elevMin + (j*elevIncr); + glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), + _centre.y() + _radius*cos(elev)*cos(az), + _centre.z() + _radius*sin(elev)); + } + glEnd(); + } - if (drawFrontSide) - { - glNormal3fv(normal.ptr()); - glBegin(GL_TRIANGLE_FAN); - glVertex3fv(_centre.ptr()); - for (int j=start; j!=end+delta; j+=delta) - { - float elev = _elevMin + (j*elevIncr); - glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), - _centre.y() + _radius*cos(elev)*cos(az), - _centre.z() + _radius*sin(elev)); - } - glEnd(); - } + if (boundaryAngle==MIN) + { + start = 0; + end = _density; + } + else + { + start = _density; + end = 0; + } + delta = end>start?1:-1; + + if (drawFrontSide) + { + glNormal3fv(normal.ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(_centre.ptr()); + for (int j=start; j!=end+delta; j+=delta) + { + float elev = _elevMin + (j*elevIncr); + glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), + _centre.y() + _radius*cos(elev)*cos(az), + _centre.z() + _radius*sin(elev)); + } + glEnd(); + } } else if(orientation == ELEV) // This is a plane at a given elevation { - const float elev = (boundaryAngle==MIN?_elevMin:_elevMax); - const float azIncr = (_azMax - _azMin)/_density; + const float elev = (boundaryAngle==MIN?_elevMin:_elevMax); + const float azIncr = (_azMax - _azMin)/_density; - // Normal - osg::Vec3 normal = osg::Vec3(cos(elev)*sin(_azMax), cos(elev)*cos(_azMax), sin(elev)) + // Normal + osg::Vec3 normal = osg::Vec3(cos(elev)*sin(_azMax), cos(elev)*cos(_azMax), sin(elev)) ^ osg::Vec3(cos(elev)*sin(_azMin), cos(elev)*cos(_azMin), sin(elev)); - if (boundaryAngle==MIN) - { - start = _density; - end = 0; - normal = -normal; // Make sure normals orientationint 'outwards' - } - else - { - start = 0; - end = _density; - } - delta = end>start?1:-1; + if (boundaryAngle==MIN) + { + start = _density; + end = 0; + normal = -normal; // Make sure normals orientationint 'outwards' + } + else + { + start = 0; + end = _density; + } + delta = end>start?1:-1; - if (drawBackSide) - { - glNormal3f(-normal.x(),-normal.y(),-normal.z()); + if (drawBackSide) + { + glNormal3f(-normal.x(),-normal.y(),-normal.z()); - // Tri fan - glBegin(GL_TRIANGLE_FAN); - glVertex3fv(_centre.ptr()); - for (int j=start; j!=end+delta; j+=delta) - { - float az = _azMin + (j*azIncr); - glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), - _centre.y() + _radius*cos(elev)*cos(az), - _centre.z() + _radius*sin(elev)); - } - glEnd(); - } - - if (boundaryAngle==MIN) - { - start = 0; - end = _density; - } - else - { - start = _density; - end = 0; - } - delta = end>start?1:-1; + // Tri fan + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(_centre.ptr()); + for (int j=start; j!=end+delta; j+=delta) + { + float az = _azMin + (j*azIncr); + glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), + _centre.y() + _radius*cos(elev)*cos(az), + _centre.z() + _radius*sin(elev)); + } + glEnd(); + } - if (drawFrontSide) - { - glNormal3fv(normal.ptr()); + if (boundaryAngle==MIN) + { + start = 0; + end = _density; + } + else + { + start = _density; + end = 0; + } + delta = end>start?1:-1; + + if (drawFrontSide) + { + glNormal3fv(normal.ptr()); + + // Tri fan + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(_centre.ptr()); + for (int j=start; j!=end+delta; j+=delta) + { + float az = _azMin + (j*azIncr); + glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), + _centre.y() + _radius*cos(elev)*cos(az), + _centre.z() + _radius*sin(elev)); + } + glEnd(); + } - // Tri fan - glBegin(GL_TRIANGLE_FAN); - glVertex3fv(_centre.ptr()); - for (int j=start; j!=end+delta; j+=delta) - { - float az = _azMin + (j*azIncr); - glVertex3f( _centre.x() + _radius*cos(elev)*sin(az), - _centre.y() + _radius*cos(elev)*cos(az), - _centre.z() + _radius*sin(elev)); - } - glEnd(); - } - } - } - + } } } diff --git a/src/osgTerrain/HeightFieldNode.cpp b/src/osgTerrain/HeightFieldNode.cpp index 166400d4e..02c810222 100644 --- a/src/osgTerrain/HeightFieldNode.cpp +++ b/src/osgTerrain/HeightFieldNode.cpp @@ -94,13 +94,13 @@ void HeightFieldNode::computeNormalMap() char* ptr = (char*) image->data(); for(unsigned int r=0;r<_heightField->getNumRows();++r) { - for(unsigned int c=0;c<_heightField->getNumColumns();++c) - { - osg::Vec3 normal = _heightField->getNormal(c,r); + for(unsigned int c=0;c<_heightField->getNumColumns();++c) + { + osg::Vec3 normal = _heightField->getNormal(c,r); (*ptr++) = (char)((normal.x()+1.0)*0.5*255); (*ptr++) = (char)((normal.y()+1.0)*0.5*255); (*ptr++) = (char)((normal.z()+1.0)*0.5*255); - } + } } setNormalMapImage(image); diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index f4da9d6ca..16a0d010b 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -352,7 +352,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite } // => word boundary detection & wrapping - if (outOfSpace) break; + if (outOfSpace) break; // move the cursor onto the next character. switch(_layout) @@ -377,7 +377,7 @@ String::iterator Text::computeLastCharacterOnLine(osg::Vec2& cursor, String::ite while (lastValidChar!=first && deliminatorSet.count(*lastValidChar)==0) { --lastValidChar; - } + } if (first!=lastValidChar) { ++lastValidChar; @@ -427,111 +427,111 @@ void Text::computeGlyphRepresentation() itr!=_text.end(); ) { - // record the start of the current line - String::iterator startOfLine_itr = itr; + // record the start of the current line + String::iterator startOfLine_itr = itr; - // find the end of the current line. - osg::Vec2 endOfLine_coords(cursor); - String::iterator endOfLine_itr = computeLastCharacterOnLine(endOfLine_coords, itr,_text.end()); + // find the end of the current line. + osg::Vec2 endOfLine_coords(cursor); + String::iterator endOfLine_itr = computeLastCharacterOnLine(endOfLine_coords, itr,_text.end()); - linelength = endOfLine_itr - startOfLine_itr; + linelength = endOfLine_itr - startOfLine_itr; - // Set line position to correct alignment. - switch(_layout) - { - case LEFT_TO_RIGHT: - { - switch(_alignment) + // Set line position to correct alignment. + switch(_layout) { - // nothing to be done for these - //case LEFT_TOP: + case LEFT_TO_RIGHT: + { + switch(_alignment) + { + // nothing to be done for these + //case LEFT_TOP: //case LEFT_CENTER: //case LEFT_BOTTOM: - //case LEFT_BASE_LINE: - //case LEFT_BOTTOM_BASE_LINE: - // break; - case CENTER_TOP: + //case LEFT_BASE_LINE: + //case LEFT_BOTTOM_BASE_LINE: + // break; + case CENTER_TOP: case CENTER_CENTER: case CENTER_BOTTOM: - case CENTER_BASE_LINE: - case CENTER_BOTTOM_BASE_LINE: - cursor.x() = (cursor.x() - endOfLine_coords.x()) * 0.5f; - break; + case CENTER_BASE_LINE: + case CENTER_BOTTOM_BASE_LINE: + cursor.x() = (cursor.x() - endOfLine_coords.x()) * 0.5f; + break; case RIGHT_TOP: - case RIGHT_CENTER: - case RIGHT_BOTTOM: - case RIGHT_BASE_LINE: - case RIGHT_BOTTOM_BASE_LINE: - cursor.x() = cursor.x() - endOfLine_coords.x(); - break; - default: - break; - } + case RIGHT_CENTER: + case RIGHT_BOTTOM: + case RIGHT_BASE_LINE: + case RIGHT_BOTTOM_BASE_LINE: + cursor.x() = cursor.x() - endOfLine_coords.x(); + break; + default: + break; + } break; - } - case RIGHT_TO_LEFT: - { - switch(_alignment) - { - case LEFT_TOP: + } + case RIGHT_TO_LEFT: + { + switch(_alignment) + { + case LEFT_TOP: case LEFT_CENTER: case LEFT_BOTTOM: - case LEFT_BASE_LINE: - case LEFT_BOTTOM_BASE_LINE: - cursor.x() = 2*cursor.x() - endOfLine_coords.x(); - break; - case CENTER_TOP: + case LEFT_BASE_LINE: + case LEFT_BOTTOM_BASE_LINE: + cursor.x() = 2*cursor.x() - endOfLine_coords.x(); + break; + case CENTER_TOP: case CENTER_CENTER: case CENTER_BOTTOM: - case CENTER_BASE_LINE: - case CENTER_BOTTOM_BASE_LINE: - cursor.x() = cursor.x() + (cursor.x() - endOfLine_coords.x()) * 0.5f; - break; - // nothing to be done for these + case CENTER_BASE_LINE: + case CENTER_BOTTOM_BASE_LINE: + cursor.x() = cursor.x() + (cursor.x() - endOfLine_coords.x()) * 0.5f; + break; + // nothing to be done for these //case RIGHT_TOP: - //case RIGHT_CENTER: - //case RIGHT_BOTTOM: - //case RIGHT_BASE_LINE: - //case RIGHT_BOTTOM_BASE_LINE: - // break; - default: - break; - } + //case RIGHT_CENTER: + //case RIGHT_BOTTOM: + //case RIGHT_BASE_LINE: + //case RIGHT_BOTTOM_BASE_LINE: + // break; + default: + break; + } break; - } - case VERTICAL: - { - switch(_alignment) - { - // TODO: current behaviour top baselines lined up in both cases - need to implement - // top of characters aligment - Question is this neccesary? - // ... otherwise, nothing to be done for these 6 cases - //case LEFT_TOP: - //case CENTER_TOP: + } + case VERTICAL: + { + switch(_alignment) + { + // TODO: current behaviour top baselines lined up in both cases - need to implement + // top of characters aligment - Question is this neccesary? + // ... otherwise, nothing to be done for these 6 cases + //case LEFT_TOP: + //case CENTER_TOP: //case RIGHT_TOP: - // break; - //case LEFT_BASE_LINE: - //case CENTER_BASE_LINE: - //case RIGHT_BASE_LINE: - // break; + // break; + //case LEFT_BASE_LINE: + //case CENTER_BASE_LINE: + //case RIGHT_BASE_LINE: + // break; case LEFT_CENTER: case CENTER_CENTER: - case RIGHT_CENTER: - cursor.y() = cursor.y() + (cursor.y() - endOfLine_coords.y()) * 0.5f; - break; - case LEFT_BOTTOM_BASE_LINE: - case CENTER_BOTTOM_BASE_LINE: - case RIGHT_BOTTOM_BASE_LINE: - cursor.y() = cursor.y() - (linelength * _characterHeight); - break; + case RIGHT_CENTER: + cursor.y() = cursor.y() + (cursor.y() - endOfLine_coords.y()) * 0.5f; + break; + case LEFT_BOTTOM_BASE_LINE: + case CENTER_BOTTOM_BASE_LINE: + case RIGHT_BOTTOM_BASE_LINE: + cursor.y() = cursor.y() - (linelength * _characterHeight); + break; case LEFT_BOTTOM: case CENTER_BOTTOM: - case RIGHT_BOTTOM: - cursor.y() = 2*cursor.y() - endOfLine_coords.y(); - break; - default: - break; - } + case RIGHT_BOTTOM: + cursor.y() = 2*cursor.y() - endOfLine_coords.y(); + break; + default: + break; + } break; } } @@ -652,7 +652,7 @@ void Text::computeGlyphRepresentation() startOfLine_coords.y() -= _characterHeight; cursor = startOfLine_coords; previous_charcode = 0; - _lineCount++; + _lineCount++; break; } case RIGHT_TO_LEFT: @@ -660,7 +660,7 @@ void Text::computeGlyphRepresentation() startOfLine_coords.y() -= _characterHeight; cursor = startOfLine_coords; previous_charcode = 0; - _lineCount++; + _lineCount++; break; } case VERTICAL: @@ -668,8 +668,8 @@ void Text::computeGlyphRepresentation() startOfLine_coords.x() += _characterHeight/_characterAspectRatio; cursor = startOfLine_coords; previous_charcode = 0; - // because _lineCount is the max vertical no. of characters.... - _lineCount = (_lineCount >linelength)?_lineCount:linelength; + // because _lineCount is the max vertical no. of characters.... + _lineCount = (_lineCount >linelength)?_lineCount:linelength; } break; } diff --git a/src/osgUtil/CullVisitor.cpp b/src/osgUtil/CullVisitor.cpp index b37b3e1ce..23c8cc991 100644 --- a/src/osgUtil/CullVisitor.cpp +++ b/src/osgUtil/CullVisitor.cpp @@ -774,7 +774,7 @@ void CullVisitor::apply(Geode& node) } if (bb.valid()) addDrawableAndDepth(drawable,&matrix,distance(bb.center(),matrix)); - else addDrawableAndDepth(drawable,&matrix,0.0f); + else addDrawableAndDepth(drawable,&matrix,0.0f); for(unsigned int i=0;i< numPopStateSetRequired; ++i) { diff --git a/src/osgUtil/DisplayRequirementsVisitor.cpp b/src/osgUtil/DisplayRequirementsVisitor.cpp index f448a66e5..440ff6de5 100644 --- a/src/osgUtil/DisplayRequirementsVisitor.cpp +++ b/src/osgUtil/DisplayRequirementsVisitor.cpp @@ -11,7 +11,7 @@ * OpenSceneGraph Public License for more details. */ #if defined(_MSC_VER) - #pragma warning( disable : 4786 ) + #pragma warning( disable : 4786 ) #endif #include diff --git a/src/osgUtil/HalfWayMapGenerator.cpp b/src/osgUtil/HalfWayMapGenerator.cpp index 995bc4849..e344f0805 100644 --- a/src/osgUtil/HalfWayMapGenerator.cpp +++ b/src/osgUtil/HalfWayMapGenerator.cpp @@ -15,14 +15,14 @@ using namespace osgUtil; HalfWayMapGenerator::HalfWayMapGenerator(const osg::Vec3 &light_direction, int texture_size) -: CubeMapGenerator(texture_size), - ldir_(light_direction) +: CubeMapGenerator(texture_size), + ldir_(light_direction) { - ldir_.normalize(); + ldir_.normalize(); } HalfWayMapGenerator::HalfWayMapGenerator(const HalfWayMapGenerator ©, const osg::CopyOp ©op) -: CubeMapGenerator(copy, copyop), - ldir_(copy.ldir_) +: CubeMapGenerator(copy, copyop), + ldir_(copy.ldir_) { } diff --git a/src/osgUtil/IntersectVisitor.cpp b/src/osgUtil/IntersectVisitor.cpp index 5fdbc262d..e9f79be59 100644 --- a/src/osgUtil/IntersectVisitor.cpp +++ b/src/osgUtil/IntersectVisitor.cpp @@ -615,7 +615,7 @@ void IntersectVisitor::apply(Billboard& node) pushMatrix(*billboard_matrix); intersect(*node.getDrawable(i)); - + popMatrix(); } diff --git a/src/osgUtil/RenderBin.cpp b/src/osgUtil/RenderBin.cpp index 3d9ec5182..ada6c6a15 100644 --- a/src/osgUtil/RenderBin.cpp +++ b/src/osgUtil/RenderBin.cpp @@ -26,8 +26,8 @@ using namespace osgUtil; class RenderBinPrototypeList : public osg::Referenced, public std::map< std::string, osg::ref_ptr > { public: - RenderBinPrototypeList() {} - ~RenderBinPrototypeList() {} + RenderBinPrototypeList() {} + ~RenderBinPrototypeList() {} }; // register a RenderStage prototype with the RenderBin prototype list. diff --git a/src/osgUtil/Simplifier.cpp b/src/osgUtil/Simplifier.cpp index d00ac0ae4..47b5e1021 100644 --- a/src/osgUtil/Simplifier.cpp +++ b/src/osgUtil/Simplifier.cpp @@ -1069,11 +1069,11 @@ struct CollectTriangleOperator EdgeCollapse::~EdgeCollapse() { - std::for_each(_edgeSet.begin(),_edgeSet.end(),dereference_clear()); + std::for_each(_edgeSet.begin(),_edgeSet.end(),dereference_clear()); - std::for_each(_triangleSet.begin(),_triangleSet.end(),dereference_clear()); - std::for_each(_pointSet.begin(),_pointSet.end(),dereference_clear()); - std::for_each(_originalPointList.begin(),_originalPointList.end(),dereference_clear()); + std::for_each(_triangleSet.begin(),_triangleSet.end(),dereference_clear()); + std::for_each(_pointSet.begin(),_pointSet.end(),dereference_clear()); + std::for_each(_originalPointList.begin(),_originalPointList.end(),dereference_clear()); }