Commit d89f78c6 authored by Mike Kremer's avatar Mike Kremer
Browse files

Fixed rendering of line node in LineSegments mode. If the color was set via...

Fixed rendering of line node in LineSegments mode. If the color was set via MaterialNode::set_color() function, OpenFlipper crashed when rendering the line. This was due to the fact that one was supposed to set as many colors (via add_color()) as points. It was never checked whether we reached the end of the color vector. So I changed this such that as long as colors are set for the vertices, those are used. And as soon as we reach the end of the colors vector, the last used color is set for rendering the line. If no color is set at all, it defaults to white.

git-svn-id: 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d310c456
......@@ -124,13 +124,20 @@ draw(GLState& /* _state */ , const DrawModes::DrawMode& _drawMode)
ConstPointIter p_it=points_.begin(), p_end=points_.end();
ConstColorIter c_it=colors_.begin();
Color c((char)255, (char)255, (char)255);
if(c_it != colors_.end()) {
c = *c_it;
int cnt = 0;
for (; p_it!=p_end; ++p_it)
if ((cnt > 0) && (cnt % 2 == 0))
if ((cnt > 0) && (cnt % 2 == 0) && (c_it+1) != colors_.end()) {
c = *c_it;
......@@ -83,6 +83,7 @@ class ACGDLLEXPORT LineNode : public MaterialNode
// typedefs
typedef ACG::Vec3uc Color;
typedef std::vector<Vec3d> PointVector;
typedef PointVector::iterator PointIter;
typedef PointVector::const_iterator ConstPointIter;
......@@ -150,6 +151,14 @@ public:
/// clear colors
void clear_colors() { colors_.clear(); }
/// Override material node's set color function in order to locally add color
void set_color(const Vec4f& _c) {
/// add point (for LineMode == PolygonMode)
void add_point(const Vec3d& _v) { points_.push_back(_v); }
Supports Markdown
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