mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 22:44:15 +02:00
testing for serialization
This commit is contained in:
parent
ff99f68f89
commit
feeba2a029
3 changed files with 26 additions and 26 deletions
|
@ -67,29 +67,28 @@ int generateColor() {
|
|||
}
|
||||
|
||||
void RenderablePolyLineEntityItem::updateGeometry() {
|
||||
if (_pointsChanged) {
|
||||
int compactColor = generateColor();
|
||||
_numVertices = 0;
|
||||
_verticesBuffer.reset(new gpu::Buffer());
|
||||
int vertexIndex = 0;
|
||||
for (int i = 0; i < _normals.size(); i++) {
|
||||
compactColor = generateColor();
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||
vertexIndex++;
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||
_verticesBuffer->append(sizeof(int), (gpu::Byte*)&_color);
|
||||
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||
vertexIndex++;
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||
_verticesBuffer->append(sizeof(int), (gpu::Byte*)_color);
|
||||
|
||||
_numVertices +=2;
|
||||
}
|
||||
_pointsChanged = false;
|
||||
int compactColor = generateColor();
|
||||
_numVertices = 0;
|
||||
_verticesBuffer.reset(new gpu::Buffer());
|
||||
int vertexIndex = 0;
|
||||
for (int i = 0; i < _normals.size(); i++) {
|
||||
compactColor = generateColor();
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||
vertexIndex++;
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||
_verticesBuffer->append(sizeof(int), (gpu::Byte*)&_color);
|
||||
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||
vertexIndex++;
|
||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||
_verticesBuffer->append(sizeof(int), (gpu::Byte*)_color);
|
||||
|
||||
_numVertices +=2;
|
||||
}
|
||||
_pointsChanged = false;
|
||||
|
||||
_pointsChanged = false;
|
||||
|
||||
}
|
||||
|
||||
void RenderablePolyLineEntityItem::render(RenderArgs* args) {
|
||||
|
|
|
@ -129,15 +129,10 @@ bool PolyLineEntityItem::setNormals(const QVector<glm::vec3>& normals) {
|
|||
for (int i = 0; i < _points.size()-1; i++) {
|
||||
float width = _strokeWidths.at(i);
|
||||
point = _points.at(i);
|
||||
//Get tangent
|
||||
|
||||
tangent = _points.at(i+1) - point;
|
||||
glm::vec3 normal = normals.at(i);
|
||||
// qDebug() << "next point" << _points.at(i+1) << "cur point" << point;
|
||||
binormal = glm::normalize(glm::cross(tangent, normal)) * _lineWidth;
|
||||
// qDebug() << "glm cross" << glm::cross(tangent, normal);
|
||||
// qDebug()<< "binormal" << binormal;
|
||||
// qDebug() <<"dot " << glm::dot(tangent, normals.at(i));
|
||||
|
||||
if(binormal.x != binormal.x) {
|
||||
|
||||
|
|
|
@ -90,10 +90,16 @@ QScriptValue qVectorVec3ToScriptValue(QScriptEngine* engine, const QVector<glm::
|
|||
}
|
||||
|
||||
QVector<float> qVectorFloatFromScriptValue(const QScriptValue& array) {
|
||||
if(!array.isArray()) {
|
||||
return QVector<float>();
|
||||
}
|
||||
QVector<float> newVector;
|
||||
int length = array.property("length").toInteger();
|
||||
newVector.reserve(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
newVector << array.property(i).toVariant().toFloat();
|
||||
if(array.property(i).isNumber()) {
|
||||
newVector << array.property(i).toNumber();
|
||||
}
|
||||
}
|
||||
|
||||
return newVector;
|
||||
|
|
Loading…
Reference in a new issue