mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 09:11:23 -06:00
Changing the internal representation of Point / Pointf / Point3 / Pointf3 to Eigen Matrix types:
Changed the Point3 / Pointf3 to composite Eigen Vec3crd / Vec3d. Point3 is no more derived from Point, Pointf3 is no more derived from Pointf. Introduced Transform2f/3f/2d/3d types as aliases to Eigen::Transform.
This commit is contained in:
parent
86da661097
commit
f34252a27b
15 changed files with 197 additions and 303 deletions
|
|
@ -26,11 +26,6 @@
|
|||
|
||||
#include "GUI.hpp"
|
||||
|
||||
static const float UNIT_MATRIX[] = { 1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void GLIndexedVertexArray::load_mesh_flat_shading(const TriangleMesh &mesh)
|
||||
|
|
@ -218,7 +213,7 @@ GLVolume::GLVolume(float r, float g, float b, float a)
|
|||
, tverts_range(0, size_t(-1))
|
||||
, qverts_range(0, size_t(-1))
|
||||
{
|
||||
m_world_mat = std::vector<float>(UNIT_MATRIX, std::end(UNIT_MATRIX));
|
||||
m_world_mat = Transform3f::Identity();
|
||||
|
||||
color[0] = r;
|
||||
color[1] = g;
|
||||
|
|
@ -279,15 +274,14 @@ void GLVolume::set_scale_factor(float scale_factor)
|
|||
m_dirty = true;
|
||||
}
|
||||
|
||||
const std::vector<float>& GLVolume::world_matrix() const
|
||||
const Transform3f& GLVolume::world_matrix() const
|
||||
{
|
||||
if (m_dirty)
|
||||
{
|
||||
Eigen::Transform<float, 3, Eigen::Affine> m = Eigen::Transform<float, 3, Eigen::Affine>::Identity();
|
||||
m.translate(Eigen::Vector3f((float)m_origin.x(), (float)m_origin.y(), (float)m_origin.z()));
|
||||
m.rotate(Eigen::AngleAxisf(m_angle_z, Eigen::Vector3f::UnitZ()));
|
||||
m.scale(m_scale_factor);
|
||||
::memcpy((void*)m_world_mat.data(), (const void*)m.data(), 16 * sizeof(float));
|
||||
m_world_mat = Transform3f::Identity();
|
||||
m_world_mat.translate(Vec3f(m_origin.x(), m_origin.y(), 0));
|
||||
m_world_mat.rotate(Eigen::AngleAxisf(m_angle_z, Eigen::Vector3f::UnitZ()));
|
||||
m_world_mat.scale(m_scale_factor);
|
||||
m_dirty = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ private:
|
|||
// Scale factor of the volume to be rendered.
|
||||
float m_scale_factor;
|
||||
// World matrix of the volume to be rendered.
|
||||
std::vector<float> m_world_mat;
|
||||
mutable Transform3f m_world_mat;
|
||||
// Bounding box of this volume, in unscaled coordinates.
|
||||
mutable BoundingBoxf3 m_transformed_bounding_box;
|
||||
// Whether or not is needed to recalculate the world matrix.
|
||||
|
|
@ -326,7 +326,7 @@ public:
|
|||
int volume_idx() const { return (this->composite_id / 1000) % 1000; }
|
||||
int instance_idx() const { return this->composite_id % 1000; }
|
||||
|
||||
const std::vector<float>& world_matrix() const;
|
||||
const Transform3f& world_matrix() const;
|
||||
BoundingBoxf3 transformed_bounding_box() const;
|
||||
|
||||
bool empty() const { return this->indexed_vertex_array.empty(); }
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
|||
{
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
const Pointf3& size = box.size();
|
||||
m_center = box.center();
|
||||
const Pointf size = box.size().xy();
|
||||
m_center = box.center().xy();
|
||||
if (!m_keep_radius)
|
||||
{
|
||||
m_radius = Offset + ::sqrt(sqr(0.5f * size.x()) + sqr(0.5f * size.y()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue