Changing the internal representation of Point / Pointf / Point3 / Pointf3 to Eigen Matrix types, first step

This commit is contained in:
bubnikv 2018-08-14 18:33:26 +02:00
parent 077680b806
commit 86da661097
60 changed files with 1228 additions and 1206 deletions

View file

@ -35,7 +35,7 @@ void GLGizmoBase::Grabber::render(bool hover) const
float angle_z_in_deg = angle_z * 180.0f / (float)PI;
::glPushMatrix();
::glTranslatef((GLfloat)center.x, (GLfloat)center.y, 0.0f);
::glTranslatef((GLfloat)center.x(), (GLfloat)center.y(), 0.0f);
::glRotatef((GLfloat)angle_z_in_deg, 0.0f, 0.0f, 1.0f);
::glDisable(GL_CULL_FACE);
@ -266,7 +266,7 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
m_center = box.center();
if (!m_keep_radius)
{
m_radius = Offset + ::sqrt(sqr(0.5f * size.x) + sqr(0.5f * size.y));
m_radius = Offset + ::sqrt(sqr(0.5f * size.x()) + sqr(0.5f * size.y()));
m_keep_radius = true;
}
@ -299,8 +299,8 @@ void GLGizmoRotate::_render_circle() const
for (unsigned int i = 0; i < ScaleStepsCount; ++i)
{
float angle = (float)i * ScaleStepRad;
float x = m_center.x + ::cos(angle) * m_radius;
float y = m_center.y + ::sin(angle) * m_radius;
float x = m_center.x() + ::cos(angle) * m_radius;
float y = m_center.y() + ::sin(angle) * m_radius;
::glVertex3f((GLfloat)x, (GLfloat)y, 0.0f);
}
::glEnd();
@ -317,10 +317,10 @@ void GLGizmoRotate::_render_scale() const
float angle = (float)i * ScaleStepRad;
float cosa = ::cos(angle);
float sina = ::sin(angle);
float in_x = m_center.x + cosa * m_radius;
float in_y = m_center.y + sina * m_radius;
float out_x = (i % ScaleLongEvery == 0) ? m_center.x + cosa * out_radius_long : m_center.x + cosa * out_radius_short;
float out_y = (i % ScaleLongEvery == 0) ? m_center.y + sina * out_radius_long : m_center.y + sina * out_radius_short;
float in_x = m_center.x() + cosa * m_radius;
float in_y = m_center.y() + sina * m_radius;
float out_x = (i % ScaleLongEvery == 0) ? m_center.x() + cosa * out_radius_long : m_center.x() + cosa * out_radius_short;
float out_y = (i % ScaleLongEvery == 0) ? m_center.y() + sina * out_radius_long : m_center.y() + sina * out_radius_short;
::glVertex3f((GLfloat)in_x, (GLfloat)in_y, 0.0f);
::glVertex3f((GLfloat)out_x, (GLfloat)out_y, 0.0f);
}
@ -340,10 +340,10 @@ void GLGizmoRotate::_render_snap_radii() const
float angle = (float)i * step;
float cosa = ::cos(angle);
float sina = ::sin(angle);
float in_x = m_center.x + cosa * in_radius;
float in_y = m_center.y + sina * in_radius;
float out_x = m_center.x + cosa * out_radius;
float out_y = m_center.y + sina * out_radius;
float in_x = m_center.x() + cosa * in_radius;
float in_y = m_center.y() + sina * in_radius;
float out_x = m_center.x() + cosa * out_radius;
float out_y = m_center.y() + sina * out_radius;
::glVertex3f((GLfloat)in_x, (GLfloat)in_y, 0.0f);
::glVertex3f((GLfloat)out_x, (GLfloat)out_y, 0.0f);
}
@ -353,8 +353,8 @@ void GLGizmoRotate::_render_snap_radii() const
void GLGizmoRotate::_render_reference_radius() const
{
::glBegin(GL_LINES);
::glVertex3f((GLfloat)m_center.x, (GLfloat)m_center.y, 0.0f);
::glVertex3f((GLfloat)m_center.x + m_radius + GrabberOffset, (GLfloat)m_center.y, 0.0f);
::glVertex3f((GLfloat)m_center.x(), (GLfloat)m_center.y(), 0.0f);
::glVertex3f((GLfloat)m_center.x() + m_radius + GrabberOffset, (GLfloat)m_center.y(), 0.0f);
::glEnd();
}
@ -367,8 +367,8 @@ void GLGizmoRotate::_render_angle_z() const
for (unsigned int i = 0; i <= AngleResolution; ++i)
{
float angle = (float)i * step_angle;
float x = m_center.x + ::cos(angle) * ex_radius;
float y = m_center.y + ::sin(angle) * ex_radius;
float x = m_center.x() + ::cos(angle) * ex_radius;
float y = m_center.y() + ::sin(angle) * ex_radius;
::glVertex3f((GLfloat)x, (GLfloat)y, 0.0f);
}
::glEnd();
@ -377,14 +377,14 @@ void GLGizmoRotate::_render_angle_z() const
void GLGizmoRotate::_render_grabber() const
{
float grabber_radius = m_radius + GrabberOffset;
m_grabbers[0].center.x = m_center.x + ::cos(m_angle_z) * grabber_radius;
m_grabbers[0].center.y = m_center.y + ::sin(m_angle_z) * grabber_radius;
m_grabbers[0].center.x() = m_center.x() + ::cos(m_angle_z) * grabber_radius;
m_grabbers[0].center.y() = m_center.y() + ::sin(m_angle_z) * grabber_radius;
m_grabbers[0].angle_z = m_angle_z;
::glColor3fv(BaseColor);
::glBegin(GL_LINES);
::glVertex3f((GLfloat)m_center.x, (GLfloat)m_center.y, 0.0f);
::glVertex3f((GLfloat)m_grabbers[0].center.x, (GLfloat)m_grabbers[0].center.y, 0.0f);
::glVertex3f((GLfloat)m_center.x(), (GLfloat)m_center.y(), 0.0f);
::glVertex3f((GLfloat)m_grabbers[0].center.x(), (GLfloat)m_grabbers[0].center.y(), 0.0f);
::glEnd();
::memcpy((void*)m_grabbers[0].color, (const void*)HighlightColor, 3 * sizeof(float));
@ -442,7 +442,7 @@ void GLGizmoScale::on_start_dragging()
void GLGizmoScale::on_update(const Pointf& mouse_pos)
{
Pointf center(0.5 * (m_grabbers[1].center.x + m_grabbers[0].center.x), 0.5 * (m_grabbers[3].center.y + m_grabbers[0].center.y));
Pointf center(0.5 * (m_grabbers[1].center.x() + m_grabbers[0].center.x()), 0.5 * (m_grabbers[3].center.y() + m_grabbers[0].center.y()));
coordf_t orig_len = length(m_starting_drag_position - center);
coordf_t new_len = length(mouse_pos - center);
@ -455,19 +455,19 @@ void GLGizmoScale::on_render(const BoundingBoxf3& box) const
{
::glDisable(GL_DEPTH_TEST);
coordf_t min_x = box.min.x - (coordf_t)Offset;
coordf_t max_x = box.max.x + (coordf_t)Offset;
coordf_t min_y = box.min.y - (coordf_t)Offset;
coordf_t max_y = box.max.y + (coordf_t)Offset;
coordf_t min_x = box.min.x() - (coordf_t)Offset;
coordf_t max_x = box.max.x() + (coordf_t)Offset;
coordf_t min_y = box.min.y() - (coordf_t)Offset;
coordf_t max_y = box.max.y() + (coordf_t)Offset;
m_grabbers[0].center.x = min_x;
m_grabbers[0].center.y = min_y;
m_grabbers[1].center.x = max_x;
m_grabbers[1].center.y = min_y;
m_grabbers[2].center.x = max_x;
m_grabbers[2].center.y = max_y;
m_grabbers[3].center.x = min_x;
m_grabbers[3].center.y = max_y;
m_grabbers[0].center.x() = min_x;
m_grabbers[0].center.y() = min_y;
m_grabbers[1].center.x() = max_x;
m_grabbers[1].center.y() = min_y;
m_grabbers[2].center.x() = max_x;
m_grabbers[2].center.y() = max_y;
m_grabbers[3].center.x() = min_x;
m_grabbers[3].center.y() = max_y;
::glLineWidth(2.0f);
::glColor3fv(BaseColor);
@ -475,7 +475,7 @@ void GLGizmoScale::on_render(const BoundingBoxf3& box) const
::glBegin(GL_LINE_LOOP);
for (unsigned int i = 0; i < 4; ++i)
{
::glVertex3f((GLfloat)m_grabbers[i].center.x, (GLfloat)m_grabbers[i].center.y, 0.0f);
::glVertex3f((GLfloat)m_grabbers[i].center.x(), (GLfloat)m_grabbers[i].center.y(), 0.0f);
}
::glEnd();