Commit 3647ee4b authored by Sylvain Thery's avatar Sylvain Thery

bug in topo picking use dart.index

parent e0942ffc
......@@ -255,11 +255,15 @@ public:
Dart picking(typename PFP::MAP& map, int x, int y, const FunctorSelect& good=allDarts);
/**
* compute dart from color (for picking)
*/
Dart colToDart(float* color);
template<typename PFP>
void dartToCol(typename PFP::MAP& map, Dart d, float& r, float& g, float& b);
/**
* compute color from dart (for picking)
*/
void dartToCol(Dart d, float& r, float& g, float& b);
......
......@@ -253,19 +253,6 @@ void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const typename PFP::TV
}
template<typename PFP>
void Topo3Render::dartToCol(typename PFP::MAP& map, Dart d, float& r, float& g, float& b)
{
// unsigned int lab = d.index + 1; // add one to avoid picking the black of screen
unsigned int lab =map.dartIndex(d) + 1; // add one to avoid picking the black of screen
r = float(lab%255) / 255.0f; lab = lab/255;
g = float(lab%255) / 255.0f; lab = lab/255;
b = float(lab%255) / 255.0f; lab = lab/255;
if (lab!=0)
CGoGNerr << "Error picking color, too many darts"<< CGoGNendl;
}
template<typename PFP>
void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good)
......@@ -281,7 +268,7 @@ void Topo3Render::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& g
if (nb < m_nbDarts)
{
float r,g,b;
dartToCol<PFP>(map, d, r,g,b);
dartToCol(d, r,g,b);
float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO
*local++ = r;
......
......@@ -115,18 +115,35 @@ protected:
Utils::ShaderColorPerVertex* m_shader2;
/**
* compute color from dart index (for color picking)
*/
Dart colToDart(float* color);
template<typename PFP>
void dartToCol(typename PFP::MAP& map, Dart d, float& r, float& g, float& b);
/**
* compute dart from color (for color picking)
*/
void dartToCol(Dart d, float& r, float& g, float& b);
/**
* pick the color in the rendered image
*/
Dart pickColor(unsigned int x, unsigned int y);
/**
* affect a color to each dart
*/
template<typename PFP>
void setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& good);
/**
* save colors before picking
*/
void pushColors();
/**
* restore colors after picking
*/
void popColors();
public:
......
......@@ -361,18 +361,6 @@ void TopoRender::updateDataGMap(typename PFP::MAP& mapx, const typename PFP::TVE
}
template<typename PFP>
void TopoRender::dartToCol(typename PFP::MAP& map, Dart d, float& r, float& g, float& b)
{
unsigned int lab = map.dartIndex(d) + 1; // add one to avoid picking the black of screen
r = float(lab%255) / 255.0f; lab = lab/255;
g = float(lab%255) / 255.0f; lab = lab/255;
b = float(lab%255) / 255.0f; lab = lab/255;
if (lab!=0)
CGoGNerr << "Error picking color, too many darts"<< CGoGNendl;
}
template<typename PFP>
......@@ -389,7 +377,7 @@ void TopoRender::setDartsIdColor(typename PFP::MAP& map, const FunctorSelect& go
if (nb < m_nbDarts)
{
float r,g,b;
dartToCol<PFP>(map,d, r,g,b);
dartToCol(d, r,g,b);
float* local = colorBuffer+3*m_attIndex[d]; // get the right position in VBO
*local++ = r;
*local++ = g;
......
......@@ -322,6 +322,21 @@ Dart Topo3Render::colToDart(float* color)
}
void Topo3Render::dartToCol(Dart d, float& r, float& g, float& b)
{
// here use dart.index beacause it is what we want (and not map.dartIndex(d) !!)
unsigned int lab = d.index + 1; // add one to avoid picking the black of screen
r = float(lab%255) / 255.0f; lab = lab/255;
g = float(lab%255) / 255.0f; lab = lab/255;
b = float(lab%255) / 255.0f; lab = lab/255;
if (lab!=0)
CGoGNerr << "Error picking color, too many darts"<< CGoGNendl;
}
Dart Topo3Render::pickColor(unsigned int x, unsigned int y)
{
//more easy picking for
......
......@@ -215,6 +215,19 @@ Dart TopoRender::colToDart(float* color)
}
void TopoRender::dartToCol(Dart d, float& r, float& g, float& b)
{
// here use d.index beacause it is what we want (and not map.dartIndex(d) !!)
unsigned int lab = d.index + 1; // add one to avoid picking the black of screen
r = float(lab%255) / 255.0f; lab = lab/255;
g = float(lab%255) / 255.0f; lab = lab/255;
b = float(lab%255) / 255.0f; lab = lab/255;
if (lab!=0)
CGoGNerr << "Error picking color, too many darts"<< CGoGNendl;
}
Dart TopoRender::pickColor(unsigned int x, unsigned int y)
{
......
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