Commit 7a993e26 authored by Jan Möbius's avatar Jan Möbius
Browse files

Switched bounding box action to doubles

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7994 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fd3cdc6a
...@@ -154,7 +154,7 @@ public: ...@@ -154,7 +154,7 @@ public:
_bbMax since they may already store values of previous nodes' _bbMax since they may already store values of previous nodes'
bounding box computation. bounding box computation.
*/ */
virtual void boundingBox(Vec3f& /* _bbMin */, Vec3f& /*_bbMax*/ ) {} virtual void boundingBox(Vec3d& /* _bbMin */, Vec3d& /*_bbMax*/ ) {}
/** This function is called when traversing the scene graph and /** This function is called when traversing the scene graph and
arriving at this node. It can be used to store GL states that arriving at this node. It can be used to store GL states that
......
...@@ -94,7 +94,7 @@ CoordFrameNode::availableDrawModes() const ...@@ -94,7 +94,7 @@ CoordFrameNode::availableDrawModes() const
void void
CoordFrameNode::boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) CoordFrameNode::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
_bbMin.minimize(bb_min_); _bbMin.minimize(bb_min_);
_bbMax.maximize(bb_max_); _bbMax.maximize(bb_max_);
......
...@@ -95,7 +95,7 @@ public: ...@@ -95,7 +95,7 @@ public:
/// return available draw modes /// return available draw modes
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive /// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
...@@ -105,9 +105,9 @@ public: ...@@ -105,9 +105,9 @@ public:
/// set bounding box /// set bounding box
void set_bounding_box(const Vec3f& _bb_min, const Vec3f& _bb_max); void set_bounding_box(const Vec3f& _bb_min, const Vec3f& _bb_max);
/// get bounding box /// get bounding box
const Vec3f& bb_min() const { return bb_min_; } const Vec3d& bb_min() const { return bb_min_; }
/// get bounding box /// get bounding box
const Vec3f& bb_max() const { return bb_max_; } const Vec3d& bb_max() const { return bb_max_; }
/// get x-plane container /// get x-plane container
...@@ -160,7 +160,7 @@ private: ...@@ -160,7 +160,7 @@ private:
// extend of bounding box // extend of bounding box
Vec3f bb_min_, bb_max_; Vec3d bb_min_, bb_max_;
// planes in x-, y-, z-direction // planes in x-, y-, z-direction
std::vector<float> x_planes_, y_planes_, z_planes_; std::vector<float> x_planes_, y_planes_, z_planes_;
......
...@@ -68,7 +68,7 @@ namespace SceneGraph { ...@@ -68,7 +68,7 @@ namespace SceneGraph {
void void
CoordsysNode:: CoordsysNode::
boundingBox(Vec3f& /*_bbMin*/, Vec3f& /*_bbMax*/) boundingBox(Vec3d& /*_bbMin*/, Vec3d& /*_bbMax*/)
{ {
//_bbMin.minimize( Vect3f ) //_bbMin.minimize( Vect3f )
} }
......
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// draw Coordsys /// draw Coordsys
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
......
...@@ -67,7 +67,7 @@ namespace SceneGraph { ...@@ -67,7 +67,7 @@ namespace SceneGraph {
void void
GlutPrimitiveNode:: GlutPrimitiveNode::
boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
if (_bbMin[0] > -size_) _bbMin[0] = -size_; if (_bbMin[0] > -size_) _bbMin[0] = -size_;
if (_bbMin[1] > -size_) _bbMin[1] = -size_; if (_bbMin[1] > -size_) _bbMin[1] = -size_;
......
...@@ -131,7 +131,7 @@ public: ...@@ -131,7 +131,7 @@ public:
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive /// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
......
...@@ -98,7 +98,7 @@ GridNode::availableDrawModes() const ...@@ -98,7 +98,7 @@ GridNode::availableDrawModes() const
void void
GridNode::boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) GridNode::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
_bbMin.minimize(bb_min_); _bbMin.minimize(bb_min_);
_bbMax.maximize(bb_max_); _bbMax.maximize(bb_max_);
......
...@@ -94,7 +94,7 @@ public: ...@@ -94,7 +94,7 @@ public:
/// return available draw modes /// return available draw modes
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive /// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
/// don't pick me /// don't pick me
...@@ -117,8 +117,8 @@ private: ...@@ -117,8 +117,8 @@ private:
float gridSize_; float gridSize_;
/// bounding box /// bounding box
Vec3f bb_min_; Vec3d bb_min_;
Vec3f bb_max_; Vec3d bb_max_;
/// colors for the grid /// colors for the grid
Vec3f baseLineColor_; Vec3f baseLineColor_;
......
...@@ -65,14 +65,23 @@ namespace SceneGraph { ...@@ -65,14 +65,23 @@ namespace SceneGraph {
void void
LineNode:: LineNode::
boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
Vec3f bbMin(FLT_MAX,FLT_MAX,FLT_MAX);
Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX);
ConstPointIter p_it=points_.begin(), p_end=points_.end(); ConstPointIter p_it=points_.begin(), p_end=points_.end();
for (; p_it!=p_end; ++p_it) for (; p_it!=p_end; ++p_it)
{ {
_bbMin.minimize(*p_it); bbMax.maximize(*p_it);
_bbMax.maximize(*p_it); bbMin.minimize(*p_it);
} }
Vec3d bbMind = ACG::Vec3d(bbMin);
Vec3d bbMaxd = ACG::Vec3d(bbMax);
_bbMin.minimize(bbMind);
_bbMax.maximize(bbMaxd);
} }
......
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// draw lines and normals /// draw lines and normals
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
......
...@@ -145,7 +145,7 @@ MeshNodeT<Mesh>:: ...@@ -145,7 +145,7 @@ MeshNodeT<Mesh>::
template<class Mesh> template<class Mesh>
void void
MeshNodeT<Mesh>:: MeshNodeT<Mesh>::
boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
_bbMin.minimize(bbMin_); _bbMin.minimize(bbMin_);
_bbMax.maximize(bbMax_); _bbMax.maximize(bbMax_);
...@@ -389,15 +389,15 @@ update_geometry() ...@@ -389,15 +389,15 @@ update_geometry()
updateEdgeList_ = true; updateEdgeList_ = true;
updateAnyList_ = true; updateAnyList_ = true;
bbMin_ = Vec3f(FLT_MAX, FLT_MAX, FLT_MAX); bbMin_ = Vec3d(FLT_MAX, FLT_MAX, FLT_MAX);
bbMax_ = Vec3f(-FLT_MAX, -FLT_MAX, -FLT_MAX); bbMax_ = Vec3d(-FLT_MAX, -FLT_MAX, -FLT_MAX);
typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()), typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()),
v_end(mesh_.vertices_end()); v_end(mesh_.vertices_end());
for (; v_it!=v_end; ++v_it) for (; v_it!=v_end; ++v_it)
{ {
bbMin_.minimize((Vec3f)mesh_.point(v_it)); bbMin_.minimize(mesh_.point(v_it));
bbMax_.maximize((Vec3f)mesh_.point(v_it)); bbMax_.maximize(mesh_.point(v_it));
} }
if (GLEW_ARB_vertex_buffer_object) { if (GLEW_ARB_vertex_buffer_object) {
......
...@@ -104,7 +104,7 @@ public: ...@@ -104,7 +104,7 @@ public:
/// return available draw modes /// return available draw modes
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing /// drawing
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
/// picking /// picking
...@@ -253,8 +253,8 @@ private: ...@@ -253,8 +253,8 @@ private:
std::vector< ACG::Vec4uc > pickColorBuf_; std::vector< ACG::Vec4uc > pickColorBuf_;
// bounding box // bounding box
Vec3f bbMin_; Vec3d bbMin_;
Vec3f bbMax_; Vec3d bbMax_;
}; };
......
...@@ -68,13 +68,23 @@ namespace SceneGraph { ...@@ -68,13 +68,23 @@ namespace SceneGraph {
void void
OBJNode:: OBJNode::
boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
Vec3f bbMin(FLT_MAX,FLT_MAX,FLT_MAX);
Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX);
for(unsigned int i=0; i<vertices_.size(); ++i) for(unsigned int i=0; i<vertices_.size(); ++i)
{ {
_bbMin.minimize(vertices_[i]); bbMin.minimize(vertices_[i]);
_bbMax.maximize(vertices_[i]); bbMax.maximize(vertices_[i]);
} }
Vec3d bbMind = ACG::Vec3d(bbMin);
Vec3d bbMaxd = ACG::Vec3d(bbMax);
_bbMin.minimize(bbMind);
_bbMax.maximize(bbMaxd);
} }
......
...@@ -98,7 +98,7 @@ public: ...@@ -98,7 +98,7 @@ public:
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// drawing the primitive /// drawing the primitive
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
......
...@@ -54,23 +54,26 @@ namespace SceneGraph { ...@@ -54,23 +54,26 @@ namespace SceneGraph {
//== IMPLEMENTATION ========================================================== //== IMPLEMENTATION ==========================================================
void PlaneNode::boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) void PlaneNode::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
Vec3f pos = position_ - xDirection_*0.5 - yDirection_*0.5; Vec3f pos = position_ - xDirection_*0.5 - yDirection_*0.5;
//add a little offset in normal direction //add a little offset in normal direction
Vec3f pos0 = pos + normal_*0.1; Vec3d pos0 = ACG::Vec3d( pos + normal_*0.1 );
Vec3f pos1 = pos - normal_*0.1; Vec3d pos1 = ACG::Vec3d( pos - normal_*0.1 );
Vec3d xDird = ACG::Vec3d( xDirection_ );
Vec3d yDird = ACG::Vec3d( yDirection_ );
_bbMin.minimize( pos0 ); _bbMin.minimize( pos0 );
_bbMin.minimize( pos0 + xDirection_); _bbMin.minimize( pos0 + xDird);
_bbMin.minimize( pos0 + yDirection_); _bbMin.minimize( pos0 + yDird);
_bbMin.minimize( pos0 + xDirection_ + yDirection_); _bbMin.minimize( pos0 + xDird + yDird);
_bbMax.maximize( pos1 ); _bbMax.maximize( pos1 );
_bbMax.maximize( pos1 + xDirection_); _bbMax.maximize( pos1 + xDird);
_bbMax.maximize( pos1 + yDirection_); _bbMax.maximize( pos1 + yDird);
_bbMax.maximize( pos1 + xDirection_ + yDirection_); _bbMax.maximize( pos1 + xDird + yDird);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
......
...@@ -89,7 +89,7 @@ class ACGDLLEXPORT PlaneNode : public BaseNode ...@@ -89,7 +89,7 @@ class ACGDLLEXPORT PlaneNode : public BaseNode
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// draw Plane /// draw Plane
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
......
...@@ -66,12 +66,22 @@ namespace SceneGraph { ...@@ -66,12 +66,22 @@ namespace SceneGraph {
void void
PointNode:: PointNode::
boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
Vec3f bbMin(FLT_MAX,FLT_MAX,FLT_MAX);
Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX);
ConstPointIter p_it=points_.begin(), p_end=points_.end(); ConstPointIter p_it=points_.begin(), p_end=points_.end();
for (; p_it!=p_end; ++p_it) { for (; p_it!=p_end; ++p_it) {
_bbMin.minimize(*p_it); _bbMax.maximize(*p_it); bbMin.minimize(*p_it);
bbMax.maximize(*p_it);
} }
Vec3d bbMind = ACG::Vec3d(bbMin);
Vec3d bbMaxd = ACG::Vec3d(bbMax);
_bbMin.minimize(bbMind);
_bbMax.maximize(bbMaxd);
} }
......
...@@ -106,7 +106,7 @@ public: ...@@ -106,7 +106,7 @@ public:
unsigned int availableDrawModes() const; unsigned int availableDrawModes() const;
/// update bounding box /// update bounding box
void boundingBox(Vec3f& _bbMin, Vec3f& _bbMax); void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax);
/// draw points and normals /// draw points and normals
void draw(GLState& _state, unsigned int _drawMode); void draw(GLState& _state, unsigned int _drawMode);
......
...@@ -68,12 +68,12 @@ namespace SceneGraph { ...@@ -68,12 +68,12 @@ namespace SceneGraph {
template <class PolyLine> template <class PolyLine>
void void
PolyLineNodeT<PolyLine>:: PolyLineNodeT<PolyLine>::
boundingBox(Vec3f& _bbMin, Vec3f& _bbMax) boundingBox(Vec3d& _bbMin, Vec3d& _bbMax)
{ {
for (unsigned int i=0; i< polyline_.n_vertices(); ++i) for (unsigned int i=0; i< polyline_.n_vertices(); ++i)
{ {
_bbMin.minimize((Vec3f)polyline_.point(i)); _bbMin.minimize(polyline_.point(i));
_bbMax.maximize((Vec3f)polyline_.point(i)); _bbMax.maximize(polyline_.point(i));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment