Commit 08faa652 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'master' into qtcreator-workaround

parents ba9a2c50 61f76792
......@@ -45,3 +45,14 @@ VS2013-Qt-5.5.1-x64:
artifacts:
paths:
- rel/*.exe
Mac-Cpp11:
script: "CI/ci-mac.sh"
cache:
paths:
- build-release/
tags:
- Apple
artifacts:
paths:
- build-release/*.dmg
......@@ -103,7 +103,7 @@ void ColorStack::initialize ()
//----------------------------------------------------------------------------
bool ColorStack::setMaximumIndex (unsigned int _idx)
bool ColorStack::setMaximumIndex (size_t _idx)
{
if (initialized_)
{
......@@ -117,7 +117,7 @@ bool ColorStack::setMaximumIndex (unsigned int _idx)
//----------------------------------------------------------------------------
void ColorStack::setIndex (unsigned int _idx)
void ColorStack::setIndex (size_t _idx)
{
if (initialized_)
{
......@@ -128,7 +128,7 @@ void ColorStack::setIndex (unsigned int _idx)
//----------------------------------------------------------------------------
Vec4uc ColorStack::getIndexColor (unsigned int _idx)
Vec4uc ColorStack::getIndexColor (size_t _idx)
{
if (initialized_)
{
......@@ -144,7 +144,7 @@ Vec4uc ColorStack::getIndexColor (unsigned int _idx)
//----------------------------------------------------------------------------
void ColorStack::pushIndex (unsigned int _idx)
void ColorStack::pushIndex (size_t _idx)
{
if (initialized_)
currentNode_ = currentNode_->pushIndex (_idx);
......@@ -160,12 +160,12 @@ void ColorStack::popIndex ()
//----------------------------------------------------------------------------
std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const
std::vector<size_t> ColorStack::colorToStack (Vec4uc _rgba) const
{
std::vector<unsigned int> rv(0);
std::vector<size_t> rv(0);
if (initialized_ && !error_)
{
unsigned int idx = translator_.color2index (_rgba);
const size_t idx = translator_.color2index (_rgba);
if (idx >= root_->startIndex () && idx < root_->endIndex ())
root_->colorToStack (rv, idx);
}
......@@ -174,7 +174,7 @@ std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const
//----------------------------------------------------------------------------
unsigned int ColorStack::freeIndicies() const
size_t ColorStack::freeIndicies() const
{
if (initialized_)
{
......@@ -186,7 +186,7 @@ unsigned int ColorStack::freeIndicies() const
//----------------------------------------------------------------------------
unsigned int ColorStack::currentIndex () const
size_t ColorStack::currentIndex () const
{
if (initialized_)
{
......@@ -198,7 +198,7 @@ unsigned int ColorStack::currentIndex () const
//----------------------------------------------------------------------------
ColorStack::Node::Node (unsigned int _idx, Node *_parent, ColorTranslator *_ct) :
ColorStack::Node::Node (size_t _idx, Node *_parent, ColorTranslator *_ct) :
parent_(_parent),
index_(_idx),
translator_(_ct),
......@@ -221,7 +221,7 @@ ColorStack::Node::~Node ()
//----------------------------------------------------------------------------
bool ColorStack::Node::setMaximumIndex (unsigned int _idx)
bool ColorStack::Node::setMaximumIndex (size_t _idx)
{
if (_idx == 0)
_idx = 1;
......@@ -237,7 +237,7 @@ bool ColorStack::Node::setMaximumIndex (unsigned int _idx)
//----------------------------------------------------------------------------
bool ColorStack::Node::setIndex (unsigned int _idx) const
bool ColorStack::Node::setIndex (size_t _idx) const
{
if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
{
......@@ -249,7 +249,7 @@ bool ColorStack::Node::setIndex (unsigned int _idx) const
//----------------------------------------------------------------------------
bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const
bool ColorStack::Node::getIndexColor (size_t _idx, Vec4uc &_rgba) const
{
if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
{
......@@ -261,7 +261,7 @@ bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const
//----------------------------------------------------------------------------
ColorStack::Node * ColorStack::Node::pushIndex (unsigned int _idx)
ColorStack::Node * ColorStack::Node::pushIndex (size_t _idx)
{
ColorStack::Node *n = new ColorStack::Node (_idx, this, translator_);
nodes_.push_back (n);
......@@ -278,7 +278,7 @@ ColorStack::Node * ColorStack::Node::popIndex ()
//----------------------------------------------------------------------------
void ColorStack::Node::colorToStack (std::vector<unsigned int> &_stack, unsigned int _index)
void ColorStack::Node::colorToStack (std::vector<size_t> &_stack, size_t _index)
{
if (_index >= colorStartIdx_ && _index < colorEndIdx_)
{
......
......@@ -95,31 +95,31 @@ public:
bool initialized() const { return initialized_; }
/// sets the maximum index number used in current node
bool setMaximumIndex (unsigned int _idx);
bool setMaximumIndex (size_t _idx);
/// sets the current color the given index (like glLoadName)
void setIndex (unsigned int _idx);
void setIndex (size_t _idx);
/// gets the color instead of setting it directly
Vec4uc getIndexColor (unsigned int _idx);
Vec4uc getIndexColor (size_t _idx);
/// creates a new node the stack (like glPushName)
void pushIndex (unsigned int _idx);
void pushIndex (size_t _idx);
/// pops the current node from the stack (like glPopName)
void popIndex ();
/// converts the given color to index values on the stack
std::vector<unsigned int> colorToStack (Vec4uc _rgba) const;
std::vector<size_t> colorToStack (Vec4uc _rgba) const;
/// returns maximal available index count
unsigned int freeIndicies () const;
size_t freeIndicies () const;
/// Did an error occur during picking
bool error () const { return error_ && initialized_; };
/// returns the current color index
unsigned int currentIndex () const;
size_t currentIndex () const;
private:
......@@ -127,40 +127,40 @@ private:
class Node {
public:
Node (unsigned int _idx, Node *_parent, ColorTranslator *_ct);
Node (size_t _idx, Node *_parent, ColorTranslator *_ct);
~Node ();
/// sets the maximum index number used in current node
bool setMaximumIndex (unsigned int _idx);
bool setMaximumIndex (size_t _idx);
/// sets the current color the given index (like glLoadName)
bool setIndex (unsigned int _idx) const;
bool setIndex (size_t _idx) const;
/// gets the color instead of setting it directly
bool getIndexColor (unsigned int _idx, Vec4uc &_rgba) const;
bool getIndexColor (size_t _idx, Vec4uc &_rgba) const;
/// creates a new node the stack (like glPushName)
Node * pushIndex (unsigned int _idx);
Node * pushIndex (size_t _idx);
/// pops the current node from the stack (like glPopName)
Node * popIndex ();
void colorToStack (std::vector<unsigned int> &_stack, unsigned int _index);
void colorToStack (std::vector<size_t> &_stack, size_t size_t);
unsigned int startIndex () { return startIdx_; };
unsigned int endIndex () { return endIdx_; };
unsigned int colorIndex () { return colorStartIdx_; };
size_t startIndex () const { return startIdx_; };
size_t endIndex () const { return endIdx_; };
size_t colorIndex () const { return colorStartIdx_; };
private:
Node *parent_;
unsigned int index_;
size_t index_;
ColorTranslator *translator_;
std::vector<Node *> nodes_;
unsigned int startIdx_;
unsigned int endIdx_;
unsigned int colorStartIdx_;
unsigned int colorEndIdx_;
size_t startIdx_;
size_t endIdx_;
size_t colorStartIdx_;
size_t colorEndIdx_;
};
......
......@@ -61,6 +61,7 @@
#include "ColorTranslator.hh"
#include <iostream>
#include <limits>
//== NAMESPACES ===============================================================
......@@ -81,21 +82,25 @@ initialize()
glGetIntegerv( GL_BLUE_BITS, &blue_bits_ );
glGetIntegerv( GL_ALPHA_BITS, &alpha_bits_ );
// We currently only support up to 8 bits per channel (
if (red_bits_ > 8) red_bits_ = 8;
if (green_bits_ > 8) green_bits_ = 8;
if (blue_bits_ > 8) blue_bits_ = 8;
if (alpha_bits_ > 8) alpha_bits_ = 8;
// Compute the mask to extract the component
red_mask_ = ((1 << red_bits_) - 1);
green_mask_ = ((1 << green_bits_) - 1);
blue_mask_ = ((1 << blue_bits_) - 1);
alpha_mask_ = ((1 << alpha_bits_) - 1);
// Shift required to move the component to the lowest bits
red_shift_ = 8 - red_bits_;
green_shift_ = 8 - green_bits_;
blue_shift_ = 8 - blue_bits_;
alpha_shift_ = 8 - alpha_bits_;
red_round_ = 1 << (red_shift_ - 1);
green_round_ = 1 << (green_shift_ - 1);
blue_round_ = 1 << (blue_shift_ - 1);
......@@ -110,12 +115,19 @@ initialize()
Vec4uc
ColorTranslator::
index2color(unsigned int _idx) const
index2color(const size_t _idx) const
{
assert(initialized());
unsigned char r, g, b, a;
unsigned int idx(_idx+1);
// Make sure that the number fits
if ( _idx > std::numeric_limits<unsigned int>::max() ) {
std::cerr << "Can't convert index " << _idx << " to RGBA. Number too large for unsigned int \n";
return Vec4uc(0, 0, 0, 0);
}
unsigned int idx = ( static_cast<unsigned int>(_idx) + 1);
b = ((idx & blue_mask_) << blue_shift_) | blue_round_;
idx >>= blue_bits_;
g = ((idx & green_mask_) << green_shift_) | green_round_;
......@@ -139,13 +151,18 @@ index2color(unsigned int _idx) const
//-----------------------------------------------------------------------------
int
size_t
ColorTranslator::
color2index(Vec4uc _rgba) const
color2index(const Vec4uc _rgba) const
{
assert(initialized());
// Work internally with#include <iostream> unsigned int for now
unsigned int result;
// Combine the single unsigned chars according to masks
result = _rgba[3] >> alpha_shift_;
result <<= red_bits_;
result = _rgba[0] >> red_shift_;
......@@ -154,14 +171,15 @@ color2index(Vec4uc _rgba) const
result <<= blue_bits_;
result |= _rgba[2] >> blue_shift_;
return (result-1);
// Return size_t Here
return ( static_cast<size_t>(result-1) );
}
//-----------------------------------------------------------------------------
unsigned int
size_t
ColorTranslator::max_index() const
{
assert(initialized());
......
......@@ -95,20 +95,23 @@ public:
~ColorTranslator() {};
/// init (takes current GL context)
/// init (takes current GL context to get the component sizes)
/// Can't use constructor as we might not have a context at this point.
void initialize();
/// has it been initialized?
bool initialized() const { return initialized_; }
/// index -> color (one buffer)
Vec4uc index2color(unsigned int _idx) const;
Vec4uc index2color(const size_t _idx) const;
/// color -> index (one buffer)
int color2index(Vec4uc _rgba) const;
size_t color2index(const Vec4uc _rgba) const;
/// returns maximal convertable index
unsigned int max_index() const;
/// returns maximal convertible index
size_t max_index() const;
private:
......
......@@ -385,22 +385,22 @@ private:
* @param _hh corresponding halfedge handle of this vertex
* @param _fh corresponding face handle of this vertex
*/
void readVertex(size_t _vertex,
const typename Mesh::VertexHandle _vh,
const typename Mesh::HalfedgeHandle _hh,
const typename Mesh::FaceHandle _fh);
void readVertex(size_t _vertex,
const typename Mesh::VertexHandle& _vh,
const typename Mesh::HalfedgeHandle& _hh,
const typename Mesh::FaceHandle& _fh);
/** \brief return a vertex color from mesh
*
* @param _vh mesh vertex handle
*/
unsigned int getVertexColor(const typename Mesh::VertexHandle _vh);
unsigned int getVertexColor(const typename Mesh::VertexHandle& _vh);
/** \brief return a face color from mesh
*
* @param _fh mesh face handle
*/
unsigned int getFaceColor(const typename Mesh::FaceHandle _fh);
unsigned int getFaceColor(const typename Mesh::FaceHandle& _fh);
/** \brief eventually update vertex and index buffers
*
......@@ -474,7 +474,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first vertex
*/
void drawPickingVertices_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingVertices_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized vertex picking is supported
......@@ -559,7 +559,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first edge
*/
void drawPickingEdges_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingEdges_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized face picking is supported
......@@ -628,7 +628,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first face
*/
void drawPickingFaces_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingFaces_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized face picking is supported
......@@ -734,7 +734,7 @@ public:
* @param _mvp model view projection transformation
* @param _pickOffset base picking id of the first element
*/
void drawPickingAny_opt(const GLMatrixf& _mvp, int _pickOffset);
void drawPickingAny_opt(const GLMatrixf& _mvp, size_t _pickOffset);
/** \brief Check if optimized any picking is supported
*
......
......@@ -454,7 +454,7 @@ DrawMeshT<Mesh>::rebuild()
// read all vertices
for (size_t i = 0; i < numVerts_; ++i)
readVertex(i,
mesh_.vertex_handle(i),
mesh_.vertex_handle(static_cast<unsigned int>(i)),
(typename Mesh::HalfedgeHandle)(-1),
(typename Mesh::FaceHandle)(-1));
......@@ -626,7 +626,7 @@ DrawMeshT<Mesh>::rebuild()
if (baseProp)
{
int numAttribs = baseProp->n_elements();
size_t numAttribs = baseProp->n_elements();
const void* attribData = propDesc->propDataPtr_;
meshComp_->setAttribVec( propDesc->declElementID_, numAttribs, attribData );
......@@ -753,9 +753,9 @@ DrawMeshT<Mesh>::rebuild()
template <class Mesh>
void
DrawMeshT<Mesh>::readVertex(size_t _vertex,
const typename Mesh::VertexHandle _vh,
const typename Mesh::HalfedgeHandle _hh,
const typename Mesh::FaceHandle _fh)
const typename Mesh::VertexHandle& _vh,
const typename Mesh::HalfedgeHandle& _hh,
const typename Mesh::FaceHandle& _fh)
{
static const typename Mesh::HalfedgeHandle invalidHEH(-1);
static const typename Mesh::FaceHandle invalidFH(-1);
......@@ -831,7 +831,7 @@ DrawMeshT<Mesh>::readVertex(size_t _vertex,
template <class Mesh>
unsigned int
DrawMeshT<Mesh>::getVertexColor(const typename Mesh::VertexHandle _vh)
DrawMeshT<Mesh>::getVertexColor(const typename Mesh::VertexHandle& _vh)
{
static const typename Mesh::VertexHandle invalidVH(-1);
......@@ -853,7 +853,7 @@ DrawMeshT<Mesh>::getVertexColor(const typename Mesh::VertexHandle _vh)
template <class Mesh>
unsigned int
DrawMeshT<Mesh>::getFaceColor(const typename Mesh::FaceHandle _fh)
DrawMeshT<Mesh>::getFaceColor(const typename Mesh::FaceHandle& _fh)
{
static const typename Mesh::FaceHandle invalidFH(-1);
......@@ -1689,7 +1689,7 @@ bool ACG::DrawMeshT<Mesh>::supportsPickingVertices_opt()
template <class Mesh>
void ACG::DrawMeshT<Mesh>::drawPickingVertices_opt( const GLMatrixf& _mvp, int _pickOffset )
void ACG::DrawMeshT<Mesh>::drawPickingVertices_opt( const GLMatrixf& _mvp, size_t _pickOffset )
{
// optimized version which computes picking ids in the shader
......@@ -1724,7 +1724,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingVertices_opt( const GLMatrixf& _mvp, int _
pickVertexShader_->use();
getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
pickVertexShader_->setUniform("pickVertexOffset", _pickOffset);
pickVertexShader_->setUniform("pickVertexOffset", static_cast<GLint>(_pickOffset) );
if (pickVertexMethod_ == 0)
{
......@@ -1960,7 +1960,7 @@ bool ACG::DrawMeshT<Mesh>::supportsPickingEdges_opt()
template <class Mesh>
void ACG::DrawMeshT<Mesh>::drawPickingEdges_opt( const GLMatrixf& _mvp, int _pickOffset )
void ACG::DrawMeshT<Mesh>::drawPickingEdges_opt( const GLMatrixf& _mvp, size_t _pickOffset )
{
// optimized version which computes picking ids in the shader
......@@ -1988,7 +1988,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingEdges_opt( const GLMatrixf& _mvp, int _pic
pickEdgeShader_->use();
getVertexDeclaration()->activateShaderPipeline(pickEdgeShader_);
pickEdgeShader_->setUniform("pickVertexOffset", _pickOffset);
pickEdgeShader_->setUniform("pickVertexOffset", static_cast<GLint>(_pickOffset) );
pickEdgeShader_->setUniform("mWVP", _mvp);
// draw call
......@@ -2091,7 +2091,7 @@ bool ACG::DrawMeshT<Mesh>::supportsPickingFaces_opt()
template <class Mesh>
void ACG::DrawMeshT<Mesh>::drawPickingFaces_opt( const GLMatrixf& _mvp, int _pickOffset )
void ACG::DrawMeshT<Mesh>::drawPickingFaces_opt( const GLMatrixf& _mvp, size_t _pickOffset )
{
// optimized version which computes picking ids in the shader
......@@ -2137,7 +2137,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingFaces_opt( const GLMatrixf& _mvp, int _pic
pickFaceShader_->use();
getVertexDeclaration()->activateShaderPipeline(pickFaceShader_);
pickFaceShader_->setUniform("pickFaceOffset", _pickOffset);
pickFaceShader_->setUniform("pickFaceOffset", static_cast<GLint>(_pickOffset));
pickFaceShader_->setUniform("triToFaceMap", 0);
#ifdef GL_ARB_texture_buffer_object
......@@ -2255,7 +2255,7 @@ bool ACG::DrawMeshT<Mesh>::supportsPickingAny_opt()
template <class Mesh>
void ACG::DrawMeshT<Mesh>::drawPickingAny_opt( const GLMatrixf& _mvp, int _pickOffset )
void ACG::DrawMeshT<Mesh>::drawPickingAny_opt( const GLMatrixf& _mvp, size_t _pickOffset )
{
// optimized version which computes picking ids in the shader
......
......@@ -1044,7 +1044,7 @@ void GLState::pick_init (bool _color)
//-----------------------------------------------------------------------------
bool GLState::pick_set_maximum (unsigned int _idx)
bool GLState::pick_set_maximum (size_t _idx)
{
bool rv = colorStack_.setMaximumIndex (_idx);
if (colorPicking_)
......@@ -1054,14 +1054,14 @@ bool GLState::pick_set_maximum (unsigned int _idx)
//-----------------------------------------------------------------------------
void GLState::pick_set_name (unsigned int _idx)
void GLState::pick_set_name (size_t _idx)
{
colorStack_.setIndex (_idx);
}
//-----------------------------------------------------------------------------
Vec4uc GLState::pick_get_name_color (unsigned int _idx)
Vec4uc GLState::pick_get_name_color (size_t _idx)
{
if (colorPicking_)
return colorStack_.getIndexColor (_idx);
......@@ -1070,7 +1070,7 @@ Vec4uc GLState::pick_get_name_color (unsigned int _idx)
//-----------------------------------------------------------------------------
void GLState::pick_push_name (unsigned int _idx)
void GLState::pick_push_name (size_t _idx)
{
colorStack_.pushIndex (_idx);
}
......@@ -1084,16 +1084,16 @@ void GLState::pick_pop_name ()
//-----------------------------------------------------------------------------
std::vector<unsigned int> GLState::pick_color_to_stack (Vec4uc _rgba) const
std::vector<size_t> GLState::pick_color_to_stack (Vec4uc _rgba) const
{
if (colorPicking_ && colorStack_.initialized ())
return colorStack_.colorToStack (_rgba);
return std::vector<unsigned int> ();
return std::vector<size_t> ();
}
//-----------------------------------------------------------------------------
unsigned int GLState::pick_free_indicies () const
size_t GLState::pick_free_indicies () const
{
if (colorPicking_ && colorStack_.initialized ())
return colorStack_.freeIndicies ();
......@@ -1111,7 +1111,7 @@ bool GLState::pick_error () const
//-----------------------------------------------------------------------------
unsigned int GLState::pick_current_index () const
size_t GLState::pick_current_index () const
{
if (colorPicking_)
return colorStack_.currentIndex ();
......
......@@ -193,7 +193,7 @@ public:
void set(GLint _size, GLenum _type, GLsizei _stride, const GLvoid* _ptr)
{
size = _size; type = _type; stride = _stride, pointer = _ptr;
size = _size; type = _type; stride = _stride; pointer = _ptr;
}
};
......@@ -1095,7 +1095,7 @@ public:
* If you create picking for your nodes, the values set with pick_set_name have to be between zero and