units
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "face.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
float Face::sign (QVector2D p1, QVector2D p2, QVector2D p3)
|
||||
{
|
||||
@@ -8,13 +8,8 @@ float Face::sign (QVector2D p1, QVector2D p2, QVector2D p3)
|
||||
|
||||
bool Face::PointInFace (QVector2D pt)
|
||||
{
|
||||
bool b1, b2, b3;
|
||||
|
||||
//b1 = sign(pt, v1, v2) < 0.0f;
|
||||
//b2 = sign(pt, v2, v3) < 0.0f;
|
||||
// b3 = sign(pt, v3, v1) < 0.0f;
|
||||
|
||||
return ((b1 == b2) && (b2 == b3));
|
||||
Q_UNUSED(pt);
|
||||
return true;
|
||||
}
|
||||
|
||||
Face::Face(Vertex *v1,TileVertexInfo *vi1, Vertex *v2,TileVertexInfo *vi2,Vertex *v3,TileVertexInfo *vi3)
|
||||
@@ -42,8 +37,10 @@ void Face::recalcNormal()
|
||||
QVector3D va = v1 - v2;
|
||||
QVector3D vb = v3 - v2;
|
||||
m_normal = QVector3D::crossProduct(va,vb);
|
||||
/*float norm_len = sqrt(dot(norm, norm));
|
||||
norm /= norm_len; */
|
||||
if (m_normal.z() < 0.0f) {
|
||||
m_normal = -m_normal;
|
||||
}
|
||||
m_normal.normalize();
|
||||
}
|
||||
|
||||
QVector3D Face::normal()
|
||||
@@ -51,6 +48,11 @@ QVector3D Face::normal()
|
||||
return m_normal;
|
||||
}
|
||||
|
||||
static inline bool pointMatch(const QVector2D& p1, const QVector2D& p2)
|
||||
{
|
||||
return (std::abs(p1.x() - p2.x()) < 1e-4f) && (std::abs(p1.y() - p2.y()) < 1e-4f);
|
||||
}
|
||||
|
||||
void Face::findFaces(std::vector<Face *> &vec, QVector2D s)
|
||||
{
|
||||
if (m_subface!=NULL) {
|
||||
@@ -59,11 +61,10 @@ void Face::findFaces(std::vector<Face *> &vec, QVector2D s)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (
|
||||
((m_v1->position().x() == s.x()) && (m_v1->position().y() == s.y())) ||
|
||||
((m_v2->position().x() == s.x()) && (m_v2->position().y() == s.y())) ||
|
||||
((m_v3->position().x()== s.x()) && (m_v3->position().y() == s.y()))
|
||||
) {
|
||||
if (m_v1 && m_v2 && m_v3 && (
|
||||
pointMatch(m_v1->position(), s) ||
|
||||
pointMatch(m_v2->position(), s) ||
|
||||
pointMatch(m_v3->position(), s))) {
|
||||
vec.push_back(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user