From 9427d429c17231efca9befcde448756fdceca2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Fri, 6 Dec 2019 13:12:10 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@657 a8b55f48-bf90-11e4-a774-851b48703e85 --- qglengine/core/glmesh.cpp | 13 +++++++++++++ qglengine/core/glmesh.h | 1 + 2 files changed, 14 insertions(+) diff --git a/qglengine/core/glmesh.cpp b/qglengine/core/glmesh.cpp index c5c97cc..f275541 100644 --- a/qglengine/core/glmesh.cpp +++ b/qglengine/core/glmesh.cpp @@ -342,6 +342,19 @@ void Mesh::transformPoints(const QMatrix4x4 & mat) { } +void Mesh::flipNormals() { + if (vertices_.isEmpty()) return; + for (int i = 0; i < triangles_.size(); ++i) + piSwap(triangles_[i].p1, triangles_[i].p2); + for (int i = 0; i < lines_.size(); ++i) + piSwap(lines_[i].p0, lines_[i].p1); + int ncnt = normals_.size(); + for (int i = 0; i < ncnt; ++i) + normals_[i] = -normals_[i]; + changed = hash_changed = true; +} + + void Mesh::append(const Mesh * m) { if (!m) return; if (m->isEmpty()) return; diff --git a/qglengine/core/glmesh.h b/qglengine/core/glmesh.h index 1244f2c..f882843 100644 --- a/qglengine/core/glmesh.h +++ b/qglengine/core/glmesh.h @@ -68,6 +68,7 @@ public: void rotatePoints (const double & angle, const QVector3D & a); void rotatePoints (const double & angle, const double & x, const double & y, const double & z) {rotatePoints(angle, QVector3D(x, y, z));} void transformPoints(const QMatrix4x4 & mat); + void flipNormals(); void append(const Mesh * m); bool saveToFile(const QString & filename);