mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-24 01:01:15 -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
|
|
@ -684,7 +684,15 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||
}
|
||||
v.is_modifier = model_volume->modifier;
|
||||
v.shader_outside_printer_detection_enabled = !model_volume->modifier;
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
v.set_offset(instance->get_offset());
|
||||
#else
|
||||
//################################################################################################################################
|
||||
v.set_offset(Vec3d(instance->offset(0), instance->offset(1), 0.0));
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
v.set_rotation(instance->rotation);
|
||||
v.set_scaling_factor(instance->scaling_factor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2375,7 +2375,15 @@ void GLCanvas3D::update_gizmos_data()
|
|||
ModelInstance* model_instance = model_object->instances[0];
|
||||
if (model_instance != nullptr)
|
||||
{
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
m_gizmos.set_position(model_instance->get_offset());
|
||||
#else
|
||||
//################################################################################################################################
|
||||
m_gizmos.set_position(Vec3d(model_instance->offset(0), model_instance->offset(1), 0.0));
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
m_gizmos.set_scale(model_instance->scaling_factor);
|
||||
m_gizmos.set_angle_z(model_instance->rotation);
|
||||
m_gizmos.set_flattening_data(model_object);
|
||||
|
|
@ -5355,8 +5363,16 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
|||
ModelObject* model_object = m_model->objects[obj_idx];
|
||||
if (model_object != nullptr)
|
||||
{
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
model_object->instances[instance_idx]->set_offset(volume->get_offset());
|
||||
#else
|
||||
//################################################################################################################################
|
||||
const Vec3d& offset = volume->get_offset();
|
||||
model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1));
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
model_object->invalidate_bounding_box();
|
||||
update_position_values();
|
||||
object_moved = true;
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -328,7 +328,15 @@ private:
|
|||
SourceDataSummary m_source_data;
|
||||
|
||||
std::vector<PlaneData> m_planes;
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
Pointf3s m_instances_positions;
|
||||
#else
|
||||
//################################################################################################################################
|
||||
std::vector<Vec2d> m_instances_positions;
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
Vec3d m_starting_center;
|
||||
const ModelObject* m_model_object = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -1564,9 +1564,19 @@ void update_position_values()
|
|||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
|
||||
|
||||
//################################################################################################################################
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
og->set_value("position_x", int(instance->get_offset(X)));
|
||||
og->set_value("position_y", int(instance->get_offset(Y)));
|
||||
og->set_value("position_z", int(instance->get_offset(Z)));
|
||||
#else
|
||||
//################################################################################################################################
|
||||
og->set_value("position_x", int(instance->offset(0)));
|
||||
og->set_value("position_y", int(instance->offset(1)));
|
||||
og->set_value("position_z", 0);
|
||||
//################################################################################################################################
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
//################################################################################################################################
|
||||
}
|
||||
|
||||
void update_position_values(const Vec3d& position)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue