Commit 3b5b7fc3 authored by Stefan Pfeifer's avatar Stefan Pfeifer

Fix a graphics bug and remove some unnecessary memory fuckery

parent 2dc14841
......@@ -7,9 +7,6 @@
void LimbMesh::setData(const InputData& data)
{
m_data.resize(2500*500);
m_count = 0;
// Todo: Abstract away the conversion data -> profile curve
std::vector<double> lengths = getEvalLengths(data, 100);
Curve2D profile = ArcCurve::sample(data.profile,
......@@ -18,7 +15,7 @@ void LimbMesh::setData(const InputData& data)
data.dimensions.handle_angle,
lengths);
// Calculate splined for width and heigt distributions
// Calculate splines for width and heigt distributions
CubicSpline width(data.width);
std::vector<CubicSpline> heights;
for(auto& layer: data.layers)
......@@ -154,19 +151,19 @@ std::vector<double> LimbMesh::getEvalLengths(const InputData& data, unsigned n)
return lengths;
}
const GLfloat* LimbMesh::constData() const
const GLfloat* LimbMesh::data() const
{
return m_data.constData();
}
int LimbMesh::count() const
{
return m_count;
return m_data.size();
}
int LimbMesh::vertexCount() const
{
return m_count/6;
return m_data.size()/9;
}
void LimbMesh::addQuad(const QVector3D& p0, const QVector3D& p1, const QVector3D& p2, const QVector3D& p3, const QColor& color)
......@@ -187,19 +184,15 @@ void LimbMesh::addQuad(const QVector3D& p0, const QVector3D& p1, const QVector3D
void LimbMesh::addVertex(const QVector3D& position, const QVector3D& normal, const QColor& color)
{
GLfloat* p = m_data.data() + m_count;
*p++ = position.x();
*p++ = position.y();
*p++ = position.z();
*p++ = normal.x();
*p++ = normal.y();
*p++ = normal.z();
m_data.push_back(position.x());
m_data.push_back(position.y());
m_data.push_back(position.z());
*p++ = color.redF();
*p++ = color.greenF();
*p++ = color.blueF();
m_data.push_back(normal.x());
m_data.push_back(normal.y());
m_data.push_back(normal.z());
m_count += 9;
m_data.push_back(color.redF());
m_data.push_back(color.greenF());
m_data.push_back(color.blueF());
}
......@@ -11,7 +11,7 @@ public:
LimbMesh() = default;
void setData(const InputData& data);
const GLfloat* constData() const;
const GLfloat* data() const;
int count() const;
int vertexCount() const;
......@@ -22,5 +22,4 @@ private:
std::vector<double> getEvalLengths(const InputData& data, unsigned n);
QVector<GLfloat> m_data;
int m_count;
};
......@@ -70,7 +70,7 @@ void LimbView::setData(const InputData& data)
m_logoVbo.create();
m_logoVbo.bind();
m_logoVbo.allocate(m_logo.constData(), m_logo.count() * sizeof(GLfloat));
m_logoVbo.allocate(m_logo.data(), m_logo.count()*sizeof(GLfloat));
update();
}
......@@ -217,7 +217,7 @@ void LimbView::initializeGL()
// Setup our vertex buffer object.
m_logoVbo.create();
m_logoVbo.bind();
m_logoVbo.allocate(m_logo.constData(), m_logo.count()*sizeof(GLfloat));
m_logoVbo.allocate(m_logo.data(), m_logo.count()*sizeof(GLfloat));
// Store the vertex attribute bindings for the program.
m_logoVbo.bind();
......
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