src/glcompiler.cpp

changeset 1313
4baed9f54de3
parent 1306
be85306198a2
child 1319
39d7a9642eea
equal deleted inserted replaced
1312:f2974f3ac1ab 1313:4baed9f54de3
424 case 5: surface = VboClass::ConditionalLines; vertexCount = 2; break; 424 case 5: surface = VboClass::ConditionalLines; vertexCount = 2; break;
425 default: return; 425 default: return;
426 } 426 }
427 427
428 // Determine the normals for the polygon. 428 // Determine the normals for the polygon.
429 Vertex normals[4]; 429 QVector3D normals[4];
430 auto vertexRing = ring(poly.vertices, vertexCount); 430 auto vertexRing = ring(poly.vertices, vertexCount);
431 431
432 for (int i = 0; i < vertexCount; ++i) 432 for (int i = 0; i < vertexCount; ++i)
433 { 433 {
434 const Vertex& v1 = vertexRing[i - 1]; 434 const Vertex& v1 = vertexRing[i - 1];
435 const Vertex& v2 = vertexRing[i]; 435 const Vertex& v2 = vertexRing[i];
436 const Vertex& v3 = vertexRing[i + 1]; 436 const Vertex& v3 = vertexRing[i + 1];
437 normals[i] = Vertex::crossProduct(v3 - v2, v1 - v2).normalized(); 437 normals[i] = QVector3D::crossProduct(v3 - v2, v1 - v2).normalized();
438 } 438 }
439 439
440 for (VboSubclass complement : iterateEnum<VboSubclass>()) 440 for (VboSubclass complement : iterateEnum<VboSubclass>())
441 { 441 {
442 const int vbonum = vboNumber (surface, complement); 442 const int vbonum = vboNumber (surface, complement);
446 for (int vert = 0; vert < vertexCount; ++vert) 446 for (int vert = 0; vert < vertexCount; ++vert)
447 { 447 {
448 if (complement == VboSubclass::Surfaces) 448 if (complement == VboSubclass::Surfaces)
449 { 449 {
450 // Write coordinates. Apparently Z must be flipped too? 450 // Write coordinates. Apparently Z must be flipped too?
451 vbodata << poly.vertices[vert].x() 451 vbodata << poly.vertices[vert].x
452 << -poly.vertices[vert].y() 452 << -poly.vertices[vert].y
453 << -poly.vertices[vert].z(); 453 << -poly.vertices[vert].z;
454 } 454 }
455 else if (complement == VboSubclass::Normals) 455 else if (complement == VboSubclass::Normals)
456 { 456 {
457 vbodata << normals[vert].x() 457 vbodata << normals[vert].x()
458 << -normals[vert].y() 458 << -normals[vert].y()

mercurial