Commit 16612e64 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'Warnings' into 'master'

Warnings

Silence several warnings

See merge request !164
parents f2f417c5 051b74a7
Pipeline #3269 passed with stage
in 90 minutes and 46 seconds
......@@ -105,8 +105,8 @@ class ACGDLLEXPORT DrawMeshBase {
void fillInvVertexMap(size_t n_vertices, void *data);
public:
unsigned int getNumTris() const { return numTris_; }
unsigned int getNumVerts() const { return numVerts_; }
size_t getNumTris() const { return numTris_; }
size_t getNumVerts() const { return numVerts_; }
/** \brief get mesh compiler used to create the draw mesh
*/
......@@ -385,7 +385,7 @@ private:
* @param _hh corresponding halfedge handle of this vertex
* @param _fh corresponding face handle of this vertex
*/
void readVertex(unsigned int _vertex,
void readVertex(size_t _vertex,
const typename Mesh::VertexHandle _vh,
const typename Mesh::HalfedgeHandle _hh,
const typename Mesh::FaceHandle _fh);
......@@ -929,19 +929,19 @@ private:
//========================================================================
// write functions for flexible vertex format
void writeVertexElement(void* _dstBuf, unsigned int _vertex, unsigned int _stride, unsigned int _elementOffset, unsigned int _elementSize, const void* _elementData);
void writeVertexElement(void* _dstBuf, size_t _vertex, size_t _stride, size_t _elementOffset, size_t _elementSize, const void* _elementData);
void writePosition(unsigned int _vertex, const ACG::Vec3d& _p);
void writePosition(size_t _vertex, const ACG::Vec3d& _p);
void writeNormal(unsigned int _vertex, const ACG::Vec3d& _n);
void writeNormal(size_t _vertex, const ACG::Vec3d& _n);
void writeTexcoord(unsigned int _vertex, const ACG::Vec2f& _uv);
void writeTexcoord(size_t _vertex, const ACG::Vec2f& _uv);
void writeColor(unsigned int _vertex, unsigned int _color);
void writeColor(size_t _vertex, unsigned int _color);
void writeVertexProperty(unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf);
void writeVertexProperty(size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf);
void writeVertexProperty(unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4d& _propd);
void writeVertexProperty(size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4d& _propd);
/** \brief Read one vertex from the rendering vbo.
......@@ -1103,7 +1103,7 @@ private:
return normal;
}
typename Mesh::HalfedgeHandle mapToHalfedgeHandle(int _vertexId);
typename Mesh::HalfedgeHandle mapToHalfedgeHandle(size_t _vertexId);
};
......
......@@ -513,7 +513,7 @@ DrawMeshT<Mesh>::rebuild()
#pragma omp parallel for
#endif
#endif
for (unsigned int i = 0; i < numVerts_; ++i)
for (size_t i = 0; i < numVerts_; ++i)
{
// just pick one face, srews up face colors here so color updates need a full rebuild
const typename Mesh::HalfedgeHandle hh = mapToHalfedgeHandle(i);
......@@ -752,7 +752,7 @@ DrawMeshT<Mesh>::rebuild()
template <class Mesh>
void
DrawMeshT<Mesh>::readVertex(unsigned int _vertex,
DrawMeshT<Mesh>::readVertex(size_t _vertex,
const typename Mesh::VertexHandle _vh,
const typename Mesh::HalfedgeHandle _hh,
const typename Mesh::FaceHandle _fh)
......@@ -1389,18 +1389,18 @@ void DrawMeshT<Mesh>::draw(std::map< int, GLuint>* _textureMap, bool _nonindexed
ACG::GLState::bindTexture(GL_TEXTURE_2D, (*_textureMap)[sub->id]);
if (!_nonindexed)
glDrawElements(GL_TRIANGLES, sub->numTris * 3, indexType_,
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(sub->numTris * 3), indexType_,
(GLvoid*)( (size_t)sub->startIndex * (indexType_ == GL_UNSIGNED_INT ? 4 : 2))); // offset in bytes
else
glDrawArrays(GL_TRIANGLES, sub->startIndex, sub->numTris * 3);
glDrawArrays(GL_TRIANGLES, sub->startIndex, static_cast<GLsizei>(sub->numTris * 3));
}
}
else
{
if (!_nonindexed)
glDrawElements(GL_TRIANGLES, numTris_ * 3, indexType_, 0);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(numTris_ * 3), indexType_, 0);
else
glDrawArrays(GL_TRIANGLES, 0, numTris_ * 3);
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(numTris_ * 3));
}
}
......@@ -1460,10 +1460,10 @@ void ACG::DrawMeshT<Mesh>::addTriRenderObjects(IRenderer* _renderer, const Rende
if (!_nonindexed)
ro.glDrawElements(GL_TRIANGLES, sub->numTris * 3, indexType_,
ro.glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(sub->numTris * 3), indexType_,
(GLvoid*)((size_t)sub->startIndex * (indexType_ == GL_UNSIGNED_INT ? 4 : 2))); // offset in bytes
else
ro.glDrawArrays(GL_TRIANGLES, sub->startIndex, sub->numTris * 3);
ro.glDrawArrays(GL_TRIANGLES, sub->startIndex, static_cast<GLsizei>(sub->numTris * 3) );
_renderer->addRenderObject(&ro);
}
......@@ -1471,9 +1471,9 @@ void ACG::DrawMeshT<Mesh>::addTriRenderObjects(IRenderer* _renderer, const Rende
else
{
if (!_nonindexed)
ro.glDrawElements(GL_TRIANGLES, numTris_ * 3, indexType_, 0);
ro.glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(numTris_ * 3), indexType_, 0);
else
ro.glDrawArrays(GL_TRIANGLES,0, numTris_ * 3);
ro.glDrawArrays(GL_TRIANGLES,0, static_cast<GLsizei>(numTris_ * 3));
_renderer->addRenderObject(&ro);
}
}
......@@ -1489,7 +1489,7 @@ void DrawMeshT<Mesh>::drawLines()
{
ACG::GLState::bindBuffer(GL_ELEMENT_ARRAY_BUFFER, lineIBO_);
glDrawElements(GL_LINES, mesh_.n_edges() * 2, indexType_, 0);
glDrawElements(GL_LINES, static_cast<GLsizei>(mesh_.n_edges() * 2), indexType_, 0);
}
unbindBuffers();
......@@ -1505,7 +1505,7 @@ void DrawMeshT<Mesh>::addLineRenderObjects(IRenderer* _renderer, const RenderObj
if (mesh_.n_edges())
{
ro.indexBuffer = lineIBO_;
ro.glDrawElements(GL_LINES, mesh_.n_edges() * 2, indexType_, 0);
ro.glDrawElements(GL_LINES, static_cast<GLsizei>(mesh_.n_edges() * 2), indexType_, 0);
_renderer->addRenderObject(&ro);
}
......@@ -1518,7 +1518,7 @@ void DrawMeshT<Mesh>::drawVertices()
bindBuffers();
if (numVerts_)
glDrawArrays(GL_POINTS, 0, numVerts_);
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(numVerts_));
unbindBuffers();
}
......@@ -1531,7 +1531,7 @@ void DrawMeshT<Mesh>::addPointRenderObjects(IRenderer* _renderer, const RenderOb
if (numVerts_)
{
ro.glDrawArrays(GL_POINTS, 0, numVerts_);
ro.glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(numVerts_));
_renderer->addRenderObject(&ro);
}
......@@ -1738,13 +1738,13 @@ void ACG::DrawMeshT<Mesh>::drawPickingVertices_opt( const GLMatrixf& _mvp, int _
// draw call
if (pickVertexMethod_ == 0)
glDrawArrays(GL_POINTS, 0, getNumVerts());
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(getNumVerts()));
else
{
if (pickVertexIBO_opt() && invVertexMap_)
glDrawElements(GL_POINTS, mesh_.n_vertices(), GL_UNSIGNED_INT, 0);
glDrawElements(GL_POINTS, static_cast<GLsizei>(mesh_.n_vertices()), GL_UNSIGNED_INT, 0);
else
glDrawArrays(GL_POINTS, 0, mesh_.n_vertices());
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(mesh_.n_vertices()));
}
// restore gl state
......@@ -1992,7 +1992,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingEdges_opt( const GLMatrixf& _mvp, int _pic
pickEdgeShader_->setUniform("mWVP", _mvp);
// draw call
glDrawElements(GL_LINES, mesh_.n_edges() * 2, indexType_, 0);
glDrawElements(GL_LINES, static_cast<GLsizei>(mesh_.n_edges() * 2), indexType_, 0);
// restore gl state
getVertexDeclaration()->deactivateShaderPipeline(pickEdgeShader_);
......@@ -2147,7 +2147,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingFaces_opt( const GLMatrixf& _mvp, int _pic
pickFaceShader_->setUniform("mWVP", _mvp);
// draw call
glDrawElements(GL_TRIANGLES, getNumTris() * 3, getIndexType(), 0);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(getNumTris() * 3), getIndexType(), 0);
// restore gl state
getVertexDeclaration()->deactivateShaderPipeline(pickFaceShader_);
......@@ -2452,7 +2452,7 @@ VertexDeclaration* ACG::DrawMeshT<Mesh>::getVertexDeclaration()
template<class Mesh>
typename Mesh::HalfedgeHandle ACG::DrawMeshT<Mesh>::mapToHalfedgeHandle(int _vertexId)
typename Mesh::HalfedgeHandle ACG::DrawMeshT<Mesh>::mapToHalfedgeHandle(size_t _vertexId)
{
int faceId = -1, cornerId = -1;
......@@ -2477,10 +2477,10 @@ typename Mesh::HalfedgeHandle ACG::DrawMeshT<Mesh>::mapToHalfedgeHandle(int _ver
template <class Mesh>
void ACG::DrawMeshT<Mesh>::writeVertexElement( void* _dstBuf, unsigned int _vertex, unsigned int _stride, unsigned int _elementOffset, unsigned int _elementSize, const void* _elementData )
void ACG::DrawMeshT<Mesh>::writeVertexElement( void* _dstBuf, size_t _vertex, size_t _stride, size_t _elementOffset, size_t _elementSize, const void* _elementData )
{
// byte offset
unsigned int offset = _vertex * _stride + _elementOffset;
size_t offset = _vertex * _stride + _elementOffset;
// write address
char* dst = static_cast<char*>(_dstBuf) + offset;
......@@ -2490,7 +2490,7 @@ void ACG::DrawMeshT<Mesh>::writeVertexElement( void* _dstBuf, unsigned int _vert
}
template <class Mesh>
void ACG::DrawMeshT<Mesh>::writePosition( unsigned int _vertex, const ACG::Vec3d& _n )
void ACG::DrawMeshT<Mesh>::writePosition( size_t _vertex, const ACG::Vec3d& _n )
{
// store float3 position
float f3[3] = {float(_n[0]), float(_n[1]), float(_n[2])};
......@@ -2499,7 +2499,7 @@ void ACG::DrawMeshT<Mesh>::writePosition( unsigned int _vertex, const ACG::Vec3d
}
template <class Mesh>
void ACG::DrawMeshT<Mesh>::writeNormal( unsigned int _vertex, const ACG::Vec3d& _n )
void ACG::DrawMeshT<Mesh>::writeNormal( size_t _vertex, const ACG::Vec3d& _n )
{
// store float3 normal
float f3[3] = {float(_n[0]), float(_n[1]), float(_n[2])};
......@@ -2509,22 +2509,22 @@ void ACG::DrawMeshT<Mesh>::writeNormal( unsigned int _vertex, const ACG::Vec3d&
template <class Mesh>
void ACG::DrawMeshT<Mesh>::writeTexcoord( unsigned int _vertex, const ACG::Vec2f& _uv )
void ACG::DrawMeshT<Mesh>::writeTexcoord( size_t _vertex, const ACG::Vec2f& _uv )
{
writeVertexElement(&vertices_[0], _vertex, vertexDecl_->getVertexStride(), offsetTexc_, 8, _uv.data());
}
template <class Mesh>
void ACG::DrawMeshT<Mesh>::writeColor( unsigned int _vertex, unsigned int _color )
void ACG::DrawMeshT<Mesh>::writeColor( size_t _vertex, unsigned int _color )
{
writeVertexElement(&vertices_[0], _vertex, vertexDecl_->getVertexStride(), offsetColor_, 4, &_color);
}
template <class Mesh>
void ACG::DrawMeshT<Mesh>::writeVertexProperty( unsigned int _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf )
void ACG::DrawMeshT<Mesh>::writeVertexProperty( size_t _vertex, const VertexElement* _elementDesc, const ACG::Vec4f& _propf )
{
unsigned int elementSize = VertexDeclaration::getElementSize(_elementDesc);
const size_t elementSize = VertexDeclaration::getElementSize(_elementDesc);
writeVertexElement(&vertices_[0], _vertex, vertexDecl_->getVertexStride(), _elementDesc->getByteOffset(), elementSize, _propf.data());
}
......
......@@ -3690,7 +3690,7 @@ const int* MeshCompiler::mapToOriginalFaceIDPtr() const
int MeshCompiler::mapToOriginalVertexID( const int _i, int& _faceID, int& _cornerID ) const
int MeshCompiler::mapToOriginalVertexID( const size_t _i, int& _faceID, int& _cornerID ) const
{
int positionID = -1;
......
......@@ -636,7 +636,7 @@ public:
* @param _cornerID [out] Corner of face corresponding to vertex.
* @return Position ID in input buffer
*/
int mapToOriginalVertexID(const int _i, int& _faceID, int& _cornerID) const;
int mapToOriginalVertexID(const size_t _i, int& _faceID, int& _cornerID) const;
/** Mapping from draw tri id -> input face id
*
......
......@@ -307,9 +307,9 @@ unsigned int VertexDeclaration::getNumElements() const
}
unsigned int VertexDeclaration::getGLTypeSize(unsigned int _type)
size_t VertexDeclaration::getGLTypeSize(unsigned int _type)
{
unsigned int size = 0;
size_t size = 0;
switch (_type)
{
......@@ -341,7 +341,7 @@ unsigned int VertexDeclaration::getGLTypeSize(unsigned int _type)
unsigned int VertexDeclaration::getElementSize(const VertexElement* _pElement)
size_t VertexDeclaration::getElementSize(const VertexElement* _pElement)
{
return _pElement ? getGLTypeSize(_pElement->type_) * _pElement->numElements_ : 0;
}
......
......@@ -339,11 +339,11 @@ public:
/*! get size of GL_FLOAT, GL_INT ...
*/
static unsigned int getGLTypeSize(unsigned int _type);
static size_t getGLTypeSize(unsigned int _type);
/*! get size of one vertex element
*/
static unsigned int getElementSize(const VertexElement* _pElement);
static size_t getElementSize(const VertexElement* _pElement);
/*! Check hw support for streaming instance data from vbo
*/
......
......@@ -61,7 +61,7 @@ namespace ACG {
Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
: polySize_(_pos.size()), numRemaningVertices_(_pos.size()), numTris_(0),
numReflexVertices_(0),
status_(-1), convex_(false)
ok_(false), convex_(false)
{
if (polySize_ < 3)
return;
......@@ -77,7 +77,7 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
numRemaningVertices_ = 0;
convex_ = true;
status_ = 0;
ok_ = true;
}
else
{
......@@ -89,9 +89,9 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
Vec3f n(0.0f, 0.0f, 0.0f);
for (int i = 0; i < polySize_; ++i)
for (size_t i = 0; i < polySize_; ++i)
{
int next = (i + 1) % polySize_;
const size_t next = (i + 1) % polySize_;
Vec3f a = _pos[i] - _pos[next];
Vec3f b = _pos[i] + _pos[next];
......@@ -124,7 +124,7 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
axis[1] = axis[2] % axis[0];
for (int i = 0; i < polySize_; ++i)
for (size_t i = 0; i < polySize_; ++i)
{
// project onto polygon plane
pos_[i][0] = axis[0] | _pos[i];
......@@ -135,7 +135,7 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
// create triangle fans if there is at most one concave vertex
int reflexVertexID = 0;
for (int i = 0; i < polySize_; ++i)
for (size_t i = 0; i < polySize_; ++i)
{
// test vertex (i+1)
if (isReflexVertex(pos_[i], pos_[(i + 1) % polySize_], pos_[(i + 2) % polySize_]))
......@@ -154,9 +154,9 @@ Triangulator::Triangulator(const std::vector<Vec3f>& _pos)
numTris_ = polySize_ - 2;
tris_.resize(numTris_ * 3);
numRemaningVertices_ = 0;
status_ = 0;
ok_ = true;
for (int i = 0; i < numTris_; ++i)
for (size_t i = 0; i < numTris_; ++i)
{
tris_[i * 3] = reflexVertexID;
tris_[i * 3 + 1] = (reflexVertexID + i + 1) % polySize_;
......@@ -282,10 +282,10 @@ void Triangulator::initVertexList()
{
vertices_.resize(polySize_);
reflexVertices_.clear();
for (int i = 0; i < polySize_; ++i)
for (size_t i = 0; i < polySize_; ++i)
{
int p = (i + polySize_ - 1) % polySize_;
int n = (i + 1) % polySize_;
size_t p = (i + polySize_ - 1) % polySize_;
size_t n = (i + 1) % polySize_;
vertices_[i] = RingVertex(i, isReflexVertex(pos_[p], pos_[i], pos_[n]), pos_[i], &vertices_[p], &vertices_[n]);
......@@ -302,7 +302,7 @@ int Triangulator::earClippingN3()
// O(n^3)
numTris_ = 0;
status_ = 0;
ok_ = true;
initVertexList();
......@@ -386,13 +386,13 @@ int Triangulator::earClippingN2()
// O(n^2)
numTris_ = 0;
status_ = 0;
ok_ = true;
initVertexList();
// triangulate
int numTries = 0; // # checked vertices per iteration that aren't ears
size_t numTries = 0; // # checked vertices per iteration that aren't ears
numRemaningVertices_ = polySize_; // size of currently remaining polygon
int numIterations = 0;
......@@ -439,7 +439,7 @@ int Triangulator::earClippingN2()
addEar(curVertex);
numTries = 0;
status_ = 1;
ok_ = false;
}
curVertex = curVertex->next;
......@@ -496,4 +496,4 @@ void Triangulator::addEar(RingVertex* _earTip)
}
\ No newline at end of file
}
......@@ -120,7 +120,7 @@ public:
*
* @return success true or false
*/
bool success() const { return !status_; }
bool success() const { return ok_; }
private:
......@@ -169,12 +169,12 @@ private:
void addEar(RingVertex* _earTip);
const int polySize_;
int numRemaningVertices_;
int numTris_;
int numReflexVertices_;
const size_t polySize_;
size_t numRemaningVertices_;
size_t numTris_;
size_t numReflexVertices_;
int status_;
bool ok_;
bool convex_;
......@@ -196,4 +196,4 @@ private:
//=============================================================================
#endif // ACG_TRIANGULATOR_HH defined
//=============================================================================
\ No newline at end of file
//=============================================================================
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