mirror of https://github.com/CGAL/cgal
Bugfix for negate normals.
This commit is contained in:
parent
bb117e9792
commit
cc663c5e36
|
|
@ -151,6 +151,7 @@ public:
|
|||
m_zero_x(true),
|
||||
m_zero_y(true),
|
||||
m_zero_z(true),
|
||||
m_inverse_normal(false),
|
||||
m_face_started(false)
|
||||
{}
|
||||
|
||||
|
|
@ -201,6 +202,17 @@ public:
|
|||
bool has_zero_z() const
|
||||
{ return m_zero_z; }
|
||||
|
||||
void negate_normals()
|
||||
{
|
||||
m_inverse_normal=!m_inverse_normal;
|
||||
for (std::vector<BufferType>*array=m_flat_normal_buffer; array!=nullptr;
|
||||
array=(array==m_gouraud_normal_buffer?nullptr:m_gouraud_normal_buffer))
|
||||
{
|
||||
for (std::size_t i=0; i<array->size(); ++i)
|
||||
{ (*array)[i]=-(*array)[i]; }
|
||||
}
|
||||
}
|
||||
|
||||
// 1.1) Add a point, without color. Return the index of the added point.
|
||||
template<typename KPoint>
|
||||
std::size_t add_point(const KPoint& kp)
|
||||
|
|
@ -445,7 +457,7 @@ public:
|
|||
|
||||
/// adds `kp` coordinates to `buffer`
|
||||
template<typename KPoint>
|
||||
static void add_point_in_buffer(const KPoint& kp, std::vector<float>& buffer)
|
||||
void add_point_in_buffer(const KPoint& kp, std::vector<float>& buffer)
|
||||
{
|
||||
Local_point p=get_local_point(kp);
|
||||
buffer.push_back(p.x());
|
||||
|
|
@ -455,16 +467,16 @@ public:
|
|||
|
||||
/// adds `kv` coordinates to `buffer`
|
||||
template<typename KVector>
|
||||
static void add_normal_in_buffer(const KVector& kv, std::vector<float>& buffer)
|
||||
void add_normal_in_buffer(const KVector& kv, std::vector<float>& buffer)
|
||||
{
|
||||
Local_vector n=get_local_vector(kv);
|
||||
Local_vector n=(m_inverse_normal?-get_local_vector(kv):get_local_vector(kv));
|
||||
buffer.push_back(n.x());
|
||||
buffer.push_back(n.y());
|
||||
buffer.push_back(n.z());
|
||||
}
|
||||
|
||||
///adds `acolor` RGB components to `buffer`
|
||||
static void add_color_in_buffer(const CGAL::Color& acolor, std::vector<float>& buffer)
|
||||
void add_color_in_buffer(const CGAL::Color& acolor, std::vector<float>& buffer)
|
||||
{
|
||||
buffer.push_back((float)acolor.red()/(float)255);
|
||||
buffer.push_back((float)acolor.green()/(float)255);
|
||||
|
|
@ -884,7 +896,9 @@ protected:
|
|||
bool m_zero_y; /// True iff all points have y==0
|
||||
bool m_zero_z; /// True iff all points have z==0
|
||||
|
||||
// Local variables, used when we started a new face.
|
||||
bool m_inverse_normal;;
|
||||
|
||||
// Local variables, used when we started a new face.g
|
||||
bool m_face_started;
|
||||
bool m_started_face_is_colored;
|
||||
bool m_started_face_has_normal;
|
||||
|
|
|
|||
|
|
@ -329,6 +329,9 @@ public:
|
|||
setWindowTitle(title);
|
||||
|
||||
resize(500, 450);
|
||||
|
||||
if (inverse_normal)
|
||||
{ negate_all_normals(); }
|
||||
}
|
||||
|
||||
~Basic_viewer_qt()
|
||||
|
|
@ -1261,11 +1264,8 @@ protected:
|
|||
|
||||
void negate_all_normals()
|
||||
{
|
||||
for (unsigned int k=BEGIN_NORMAL; k<END_NORMAL; ++k)
|
||||
{
|
||||
for (std::size_t i=0; i<arrays[k].size(); ++i)
|
||||
{ arrays[k][i]=-arrays[k][i]; }
|
||||
}
|
||||
m_buffer_for_mono_faces.negate_normals();
|
||||
m_buffer_for_colored_faces.negate_normals();
|
||||
}
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue