mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 16:14:35 +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() {
|
void RenderablePolyLineEntityItem::updateGeometry() {
|
||||||
if (_pointsChanged) {
|
int compactColor = generateColor();
|
||||||
int compactColor = generateColor();
|
_numVertices = 0;
|
||||||
_numVertices = 0;
|
_verticesBuffer.reset(new gpu::Buffer());
|
||||||
_verticesBuffer.reset(new gpu::Buffer());
|
int vertexIndex = 0;
|
||||||
int vertexIndex = 0;
|
for (int i = 0; i < _normals.size(); i++) {
|
||||||
for (int i = 0; i < _normals.size(); i++) {
|
compactColor = generateColor();
|
||||||
compactColor = generateColor();
|
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
vertexIndex++;
|
||||||
vertexIndex++;
|
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
_verticesBuffer->append(sizeof(int), (gpu::Byte*)&_color);
|
||||||
_verticesBuffer->append(sizeof(int), (gpu::Byte*)&_color);
|
|
||||||
|
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
||||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_vertices.at(vertexIndex));
|
vertexIndex++;
|
||||||
vertexIndex++;
|
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
||||||
_verticesBuffer->append(sizeof(glm::vec3), (const gpu::Byte*)&_normals.at(i));
|
_verticesBuffer->append(sizeof(int), (gpu::Byte*)_color);
|
||||||
_verticesBuffer->append(sizeof(int), (gpu::Byte*)_color);
|
|
||||||
|
_numVertices +=2;
|
||||||
_numVertices +=2;
|
|
||||||
}
|
|
||||||
_pointsChanged = false;
|
|
||||||
}
|
}
|
||||||
_pointsChanged = false;
|
_pointsChanged = false;
|
||||||
|
|
||||||
|
_pointsChanged = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderablePolyLineEntityItem::render(RenderArgs* args) {
|
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++) {
|
for (int i = 0; i < _points.size()-1; i++) {
|
||||||
float width = _strokeWidths.at(i);
|
float width = _strokeWidths.at(i);
|
||||||
point = _points.at(i);
|
point = _points.at(i);
|
||||||
//Get tangent
|
|
||||||
|
|
||||||
tangent = _points.at(i+1) - point;
|
tangent = _points.at(i+1) - point;
|
||||||
glm::vec3 normal = normals.at(i);
|
glm::vec3 normal = normals.at(i);
|
||||||
// qDebug() << "next point" << _points.at(i+1) << "cur point" << point;
|
|
||||||
binormal = glm::normalize(glm::cross(tangent, normal)) * _lineWidth;
|
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) {
|
if(binormal.x != binormal.x) {
|
||||||
|
|
||||||
|
|
|
@ -90,10 +90,16 @@ QScriptValue qVectorVec3ToScriptValue(QScriptEngine* engine, const QVector<glm::
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<float> qVectorFloatFromScriptValue(const QScriptValue& array) {
|
QVector<float> qVectorFloatFromScriptValue(const QScriptValue& array) {
|
||||||
|
if(!array.isArray()) {
|
||||||
|
return QVector<float>();
|
||||||
|
}
|
||||||
QVector<float> newVector;
|
QVector<float> newVector;
|
||||||
int length = array.property("length").toInteger();
|
int length = array.property("length").toInteger();
|
||||||
|
newVector.reserve(length);
|
||||||
for (int i = 0; i < length; i++) {
|
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;
|
return newVector;
|
||||||
|
|
Loading…
Reference in a new issue