mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-21 15:51:10 -06:00
1st installment of 3d offset for ModelInstance
This commit is contained in:
parent
bef19fe6da
commit
af19713a27
16 changed files with 400 additions and 7 deletions
|
@ -1233,10 +1233,27 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
|||
else
|
||||
::glColor4f(0.9f, 0.9f, 0.9f, 0.5f);
|
||||
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
for (Vec3d offset : m_instances_positions) {
|
||||
offset += dragged_offset;
|
||||
#else
|
||||
//################################################################################################################################
|
||||
for (Vec2d offset : m_instances_positions) {
|
||||
offset += to_2d(dragged_offset);
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
::glPushMatrix();
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
::glTranslated(offset(0), offset(1), offset(2));
|
||||
#else
|
||||
//################################################################################################################################
|
||||
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
::glBegin(GL_POLYGON);
|
||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
||||
|
@ -1255,9 +1272,25 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
|||
for (unsigned int i = 0; i < m_planes.size(); ++i)
|
||||
{
|
||||
::glColor3f(1.0f, 1.0f, picking_color_component(i));
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
for (const Vec3d& offset : m_instances_positions) {
|
||||
#else
|
||||
//################################################################################################################################
|
||||
for (const Vec2d& offset : m_instances_positions) {
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
::glPushMatrix();
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
::glTranslated(offset(0), offset(1), offset(2));
|
||||
#else
|
||||
//################################################################################################################################
|
||||
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
::glBegin(GL_POLYGON);
|
||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
||||
|
@ -1275,7 +1308,15 @@ void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
|||
if (m_model_object && !m_model_object->instances.empty()) {
|
||||
m_instances_positions.clear();
|
||||
for (const auto* instance : m_model_object->instances)
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
m_instances_positions.emplace_back(instance->get_offset());
|
||||
#else
|
||||
//################################################################################################################################
|
||||
m_instances_positions.emplace_back(instance->offset);
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
}
|
||||
|
||||
if (is_plane_update_necessary())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue