mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-06-04 03:04:18 +08:00
Merge branch 'full_transform' of https://github.com/prusa3d/Slic3r into dev
This commit is contained in:
commit
eac5272dc5
@ -177,6 +177,7 @@ add_library(libslic3r STATIC
|
|||||||
${LIBDIR}/libslic3r/SurfaceCollection.hpp
|
${LIBDIR}/libslic3r/SurfaceCollection.hpp
|
||||||
${LIBDIR}/libslic3r/SVG.cpp
|
${LIBDIR}/libslic3r/SVG.cpp
|
||||||
${LIBDIR}/libslic3r/SVG.hpp
|
${LIBDIR}/libslic3r/SVG.hpp
|
||||||
|
${LIBDIR}/libslic3r/Technologies.hpp
|
||||||
${LIBDIR}/libslic3r/TriangleMesh.cpp
|
${LIBDIR}/libslic3r/TriangleMesh.cpp
|
||||||
${LIBDIR}/libslic3r/TriangleMesh.hpp
|
${LIBDIR}/libslic3r/TriangleMesh.hpp
|
||||||
${LIBDIR}/libslic3r/SLABasePool.hpp
|
${LIBDIR}/libslic3r/SLABasePool.hpp
|
||||||
|
@ -1252,9 +1252,13 @@ namespace Slic3r {
|
|||||||
// we extract from the given matrix only the values currently used
|
// we extract from the given matrix only the values currently used
|
||||||
|
|
||||||
// translation
|
// translation
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec3d offset(transform(0, 3), transform(1, 3), transform(2, 3));
|
||||||
|
#else
|
||||||
double offset_x = transform(0, 3);
|
double offset_x = transform(0, 3);
|
||||||
double offset_y = transform(1, 3);
|
double offset_y = transform(1, 3);
|
||||||
double offset_z = transform(2, 3);
|
double offset_z = transform(2, 3);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
// scale
|
// scale
|
||||||
double sx = ::sqrt(sqr(transform(0, 0)) + sqr(transform(1, 0)) + sqr(transform(2, 0)));
|
double sx = ::sqrt(sqr(transform(0, 0)) + sqr(transform(1, 0)) + sqr(transform(2, 0)));
|
||||||
@ -1287,8 +1291,12 @@ namespace Slic3r {
|
|||||||
|
|
||||||
double angle_z = (rotation.axis() == Vec3d::UnitZ()) ? rotation.angle() : -rotation.angle();
|
double angle_z = (rotation.axis() == Vec3d::UnitZ()) ? rotation.angle() : -rotation.angle();
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
instance.set_offset(offset);
|
||||||
|
#else
|
||||||
instance.offset(0) = offset_x;
|
instance.offset(0) = offset_x;
|
||||||
instance.offset(1) = offset_y;
|
instance.offset(1) = offset_y;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
instance.scaling_factor = sx;
|
instance.scaling_factor = sx;
|
||||||
instance.rotation = angle_z;
|
instance.rotation = angle_z;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,12 @@
|
|||||||
// VERSION NUMBERS
|
// VERSION NUMBERS
|
||||||
// 0 : .amf, .amf.xml and .zip.amf files saved by older slic3r. No version definition in them.
|
// 0 : .amf, .amf.xml and .zip.amf files saved by older slic3r. No version definition in them.
|
||||||
// 1 : Introduction of amf versioning. No other change in data saved into amf files.
|
// 1 : Introduction of amf versioning. No other change in data saved into amf files.
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
// 2 : Added z component of offset.
|
||||||
|
const unsigned int VERSION_AMF = 2;
|
||||||
|
#else
|
||||||
const unsigned int VERSION_AMF = 1;
|
const unsigned int VERSION_AMF = 1;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
const char* SLIC3RPE_AMF_VERSION = "slic3rpe_amf_version";
|
const char* SLIC3RPE_AMF_VERSION = "slic3rpe_amf_version";
|
||||||
|
|
||||||
const char* SLIC3R_CONFIG_TYPE = "slic3rpe_config";
|
const char* SLIC3R_CONFIG_TYPE = "slic3rpe_config";
|
||||||
@ -119,19 +124,31 @@ struct AMFParserContext
|
|||||||
NODE_TYPE_INSTANCE, // amf/constellation/instance
|
NODE_TYPE_INSTANCE, // amf/constellation/instance
|
||||||
NODE_TYPE_DELTAX, // amf/constellation/instance/deltax
|
NODE_TYPE_DELTAX, // amf/constellation/instance/deltax
|
||||||
NODE_TYPE_DELTAY, // amf/constellation/instance/deltay
|
NODE_TYPE_DELTAY, // amf/constellation/instance/deltay
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
NODE_TYPE_DELTAZ, // amf/constellation/instance/deltaz
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
NODE_TYPE_RZ, // amf/constellation/instance/rz
|
NODE_TYPE_RZ, // amf/constellation/instance/rz
|
||||||
NODE_TYPE_SCALE, // amf/constellation/instance/scale
|
NODE_TYPE_SCALE, // amf/constellation/instance/scale
|
||||||
NODE_TYPE_METADATA, // anywhere under amf/*/metadata
|
NODE_TYPE_METADATA, // anywhere under amf/*/metadata
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Instance {
|
struct Instance {
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Instance() : deltax_set(false), deltay_set(false), deltaz_set(false), rz_set(false), scale_set(false) {}
|
||||||
|
#else
|
||||||
Instance() : deltax_set(false), deltay_set(false), rz_set(false), scale_set(false) {}
|
Instance() : deltax_set(false), deltay_set(false), rz_set(false), scale_set(false) {}
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
// Shift in the X axis.
|
// Shift in the X axis.
|
||||||
float deltax;
|
float deltax;
|
||||||
bool deltax_set;
|
bool deltax_set;
|
||||||
// Shift in the Y axis.
|
// Shift in the Y axis.
|
||||||
float deltay;
|
float deltay;
|
||||||
bool deltay_set;
|
bool deltay_set;
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
// Shift in the Z axis.
|
||||||
|
float deltaz;
|
||||||
|
bool deltaz_set;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
// Rotation around the Z axis.
|
// Rotation around the Z axis.
|
||||||
float rz;
|
float rz;
|
||||||
bool rz_set;
|
bool rz_set;
|
||||||
@ -254,6 +271,10 @@ void AMFParserContext::startElement(const char *name, const char **atts)
|
|||||||
node_type_new = NODE_TYPE_DELTAX;
|
node_type_new = NODE_TYPE_DELTAX;
|
||||||
else if (strcmp(name, "deltay") == 0)
|
else if (strcmp(name, "deltay") == 0)
|
||||||
node_type_new = NODE_TYPE_DELTAY;
|
node_type_new = NODE_TYPE_DELTAY;
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
else if (strcmp(name, "deltaz") == 0)
|
||||||
|
node_type_new = NODE_TYPE_DELTAZ;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
else if (strcmp(name, "rz") == 0)
|
else if (strcmp(name, "rz") == 0)
|
||||||
node_type_new = NODE_TYPE_RZ;
|
node_type_new = NODE_TYPE_RZ;
|
||||||
else if (strcmp(name, "scale") == 0)
|
else if (strcmp(name, "scale") == 0)
|
||||||
@ -314,7 +335,15 @@ void AMFParserContext::characters(const XML_Char *s, int len)
|
|||||||
{
|
{
|
||||||
switch (m_path.size()) {
|
switch (m_path.size()) {
|
||||||
case 4:
|
case 4:
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
if (m_path.back() == NODE_TYPE_DELTAX ||
|
||||||
|
m_path.back() == NODE_TYPE_DELTAY ||
|
||||||
|
m_path.back() == NODE_TYPE_DELTAZ ||
|
||||||
|
m_path.back() == NODE_TYPE_RZ ||
|
||||||
|
m_path.back() == NODE_TYPE_SCALE)
|
||||||
|
#else
|
||||||
if (m_path.back() == NODE_TYPE_DELTAX || m_path.back() == NODE_TYPE_DELTAY || m_path.back() == NODE_TYPE_RZ || m_path.back() == NODE_TYPE_SCALE)
|
if (m_path.back() == NODE_TYPE_DELTAX || m_path.back() == NODE_TYPE_DELTAY || m_path.back() == NODE_TYPE_RZ || m_path.back() == NODE_TYPE_SCALE)
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
m_value[0].append(s, len);
|
m_value[0].append(s, len);
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
@ -354,6 +383,14 @@ void AMFParserContext::endElement(const char * /* name */)
|
|||||||
m_instance->deltay_set = true;
|
m_instance->deltay_set = true;
|
||||||
m_value[0].clear();
|
m_value[0].clear();
|
||||||
break;
|
break;
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
case NODE_TYPE_DELTAZ:
|
||||||
|
assert(m_instance);
|
||||||
|
m_instance->deltaz = float(atof(m_value[0].c_str()));
|
||||||
|
m_instance->deltaz_set = true;
|
||||||
|
m_value[0].clear();
|
||||||
|
break;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
case NODE_TYPE_RZ:
|
case NODE_TYPE_RZ:
|
||||||
assert(m_instance);
|
assert(m_instance);
|
||||||
m_instance->rz = float(atof(m_value[0].c_str()));
|
m_instance->rz = float(atof(m_value[0].c_str()));
|
||||||
@ -498,8 +535,12 @@ void AMFParserContext::endDocument()
|
|||||||
for (const Instance &instance : object.second.instances)
|
for (const Instance &instance : object.second.instances)
|
||||||
if (instance.deltax_set && instance.deltay_set) {
|
if (instance.deltax_set && instance.deltay_set) {
|
||||||
ModelInstance *mi = m_model.objects[object.second.idx]->add_instance();
|
ModelInstance *mi = m_model.objects[object.second.idx]->add_instance();
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
mi->set_offset(Vec3d((double)instance.deltax, (double)instance.deltay, (double)instance.deltaz));
|
||||||
|
#else
|
||||||
mi->offset(0) = instance.deltax;
|
mi->offset(0) = instance.deltax;
|
||||||
mi->offset(1) = instance.deltay;
|
mi->offset(1) = instance.deltay;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
mi->rotation = instance.rz_set ? instance.rz : 0.f;
|
mi->rotation = instance.rz_set ? instance.rz : 0.f;
|
||||||
mi->scaling_factor = instance.scale_set ? instance.scale : 1.f;
|
mi->scaling_factor = instance.scale_set ? instance.scale : 1.f;
|
||||||
}
|
}
|
||||||
@ -800,12 +841,21 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
|
|||||||
" <instance objectid=\"" PRINTF_ZU "\">\n"
|
" <instance objectid=\"" PRINTF_ZU "\">\n"
|
||||||
" <deltax>%lf</deltax>\n"
|
" <deltax>%lf</deltax>\n"
|
||||||
" <deltay>%lf</deltay>\n"
|
" <deltay>%lf</deltay>\n"
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
" <deltaz>%lf</deltaz>\n"
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
" <rz>%lf</rz>\n"
|
" <rz>%lf</rz>\n"
|
||||||
" <scale>%lf</scale>\n"
|
" <scale>%lf</scale>\n"
|
||||||
" </instance>\n",
|
" </instance>\n",
|
||||||
object_id,
|
object_id,
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
instance->get_offset(X),
|
||||||
|
instance->get_offset(Y),
|
||||||
|
instance->get_offset(Z),
|
||||||
|
#else
|
||||||
instance->offset(0),
|
instance->offset(0),
|
||||||
instance->offset(1),
|
instance->offset(1),
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
instance->rotation,
|
instance->rotation,
|
||||||
instance->scaling_factor);
|
instance->scaling_factor);
|
||||||
//FIXME missing instance->scaling_factor
|
//FIXME missing instance->scaling_factor
|
||||||
|
@ -166,7 +166,11 @@ bool load_prus(const char *path, Model *model)
|
|||||||
float trafo[3][4] = { 0 };
|
float trafo[3][4] = { 0 };
|
||||||
double instance_rotation = 0.;
|
double instance_rotation = 0.;
|
||||||
double instance_scaling_factor = 1.f;
|
double instance_scaling_factor = 1.f;
|
||||||
Vec2d instance_offset(0., 0.);
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec3d instance_offset = Vec3d::Zero();
|
||||||
|
#else
|
||||||
|
Vec2d instance_offset(0., 0.);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
bool trafo_set = false;
|
bool trafo_set = false;
|
||||||
unsigned int group_id = (unsigned int)-1;
|
unsigned int group_id = (unsigned int)-1;
|
||||||
unsigned int extruder_id = (unsigned int)-1;
|
unsigned int extruder_id = (unsigned int)-1;
|
||||||
@ -207,8 +211,12 @@ bool load_prus(const char *path, Model *model)
|
|||||||
for (size_t c = 0; c < 3; ++ c)
|
for (size_t c = 0; c < 3; ++ c)
|
||||||
trafo[r][c] += mat_trafo(r, c);
|
trafo[r][c] += mat_trafo(r, c);
|
||||||
}
|
}
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
instance_offset = Vec3d((double)(position[0] - zero[0]), (double)(position[1] - zero[1]), (double)(position[2] - zero[2]));
|
||||||
|
#else
|
||||||
instance_offset(0) = position[0] - zero[0];
|
instance_offset(0) = position[0] - zero[0];
|
||||||
instance_offset(1) = position[1] - zero[1];
|
instance_offset(1) = position[1] - zero[1];
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
trafo[2][3] = position[2] / instance_scaling_factor;
|
trafo[2][3] = position[2] / instance_scaling_factor;
|
||||||
trafo_set = true;
|
trafo_set = true;
|
||||||
}
|
}
|
||||||
@ -360,8 +368,12 @@ bool load_prus(const char *path, Model *model)
|
|||||||
ModelInstance *instance = model_object->add_instance();
|
ModelInstance *instance = model_object->add_instance();
|
||||||
instance->rotation = instance_rotation;
|
instance->rotation = instance_rotation;
|
||||||
instance->scaling_factor = instance_scaling_factor;
|
instance->scaling_factor = instance_scaling_factor;
|
||||||
instance->offset = instance_offset;
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
++ num_models;
|
instance->set_offset(instance_offset);
|
||||||
|
#else
|
||||||
|
instance->offset = instance_offset;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
++num_models;
|
||||||
if (group_id != (size_t)-1)
|
if (group_id != (size_t)-1)
|
||||||
group_to_model_object[group_id] = model_object;
|
group_to_model_object[group_id] = model_object;
|
||||||
} else {
|
} else {
|
||||||
|
@ -242,10 +242,19 @@ void Model::center_instances_around_point(const Vec2d &point)
|
|||||||
for (size_t i = 0; i < o->instances.size(); ++ i)
|
for (size_t i = 0; i < o->instances.size(); ++ i)
|
||||||
bb.merge(o->instance_bounding_box(i, false));
|
bb.merge(o->instance_bounding_box(i, false));
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec2d shift2 = point - to_2d(bb.center());
|
||||||
|
Vec3d shift3 = Vec3d(shift2(0), shift2(1), 0.0);
|
||||||
|
#else
|
||||||
Vec2d shift = point - 0.5 * to_2d(bb.size()) - to_2d(bb.min);
|
Vec2d shift = point - 0.5 * to_2d(bb.size()) - to_2d(bb.min);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
for (ModelObject *o : this->objects) {
|
for (ModelObject *o : this->objects) {
|
||||||
for (ModelInstance *i : o->instances)
|
for (ModelInstance *i : o->instances)
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
i->set_offset(i->get_offset() + shift3);
|
||||||
|
#else
|
||||||
i->offset += shift;
|
i->offset += shift;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
o->invalidate_bounding_box();
|
o->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,8 +320,13 @@ bool Model::arrange_objects(coordf_t dist, const BoundingBoxf* bb)
|
|||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
for (ModelObject *o : this->objects) {
|
for (ModelObject *o : this->objects) {
|
||||||
for (ModelInstance *i : o->instances) {
|
for (ModelInstance *i : o->instances) {
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec2d offset_xy = positions[idx] - instance_centers[idx];
|
||||||
|
i->set_offset(Vec3d(offset_xy(0), offset_xy(1), i->get_offset(Z)));
|
||||||
|
#else
|
||||||
i->offset = positions[idx] - instance_centers[idx];
|
i->offset = positions[idx] - instance_centers[idx];
|
||||||
++ idx;
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
++idx;
|
||||||
}
|
}
|
||||||
o->invalidate_bounding_box();
|
o->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
@ -336,7 +350,11 @@ void Model::duplicate(size_t copies_num, coordf_t dist, const BoundingBoxf* bb)
|
|||||||
for (const ModelInstance *i : instances) {
|
for (const ModelInstance *i : instances) {
|
||||||
for (const Vec2d &pos : positions) {
|
for (const Vec2d &pos : positions) {
|
||||||
ModelInstance *instance = o->add_instance(*i);
|
ModelInstance *instance = o->add_instance(*i);
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
instance->set_offset(instance->get_offset() + Vec3d(pos(0), pos(1), 0.0));
|
||||||
|
#else
|
||||||
instance->offset += pos;
|
instance->offset += pos;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o->invalidate_bounding_box();
|
o->invalidate_bounding_box();
|
||||||
@ -366,13 +384,21 @@ void Model::duplicate_objects_grid(size_t x, size_t y, coordf_t dist)
|
|||||||
ModelObject* object = this->objects.front();
|
ModelObject* object = this->objects.front();
|
||||||
object->clear_instances();
|
object->clear_instances();
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec3d ext_size = object->bounding_box().size() + dist * Vec3d::Ones();
|
||||||
|
#else
|
||||||
Vec3d size = object->bounding_box().size();
|
Vec3d size = object->bounding_box().size();
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
for (size_t x_copy = 1; x_copy <= x; ++x_copy) {
|
for (size_t x_copy = 1; x_copy <= x; ++x_copy) {
|
||||||
for (size_t y_copy = 1; y_copy <= y; ++y_copy) {
|
for (size_t y_copy = 1; y_copy <= y; ++y_copy) {
|
||||||
ModelInstance* instance = object->add_instance();
|
ModelInstance* instance = object->add_instance();
|
||||||
instance->offset(0) = (size(0) + dist) * (x_copy-1);
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
instance->offset(1) = (size(1) + dist) * (y_copy-1);
|
instance->set_offset(Vec3d(ext_size(0) * (double)(x_copy - 1), ext_size(1) * (double)(y_copy - 1), 0.0));
|
||||||
|
#else
|
||||||
|
instance->offset(0) = (size(0) + dist) * (x_copy - 1);
|
||||||
|
instance->offset(1) = (size(1) + dist) * (y_copy - 1);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,12 +702,21 @@ void ModelObject::center_around_origin()
|
|||||||
this->translate(shift);
|
this->translate(shift);
|
||||||
this->origin_translation += shift;
|
this->origin_translation += shift;
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
// set z to zero, translation in z has already been done within the mesh
|
||||||
|
shift(2) = 0.0;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
if (!this->instances.empty()) {
|
if (!this->instances.empty()) {
|
||||||
for (ModelInstance *i : this->instances) {
|
for (ModelInstance *i : this->instances) {
|
||||||
// apply rotation and scaling to vector as well before translating instance,
|
// apply rotation and scaling to vector as well before translating instance,
|
||||||
// in order to leave final position unaltered
|
// in order to leave final position unaltered
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
i->set_offset(i->get_offset() + i->transform_vector(-shift, true));
|
||||||
|
#else
|
||||||
Vec3d i_shift = i->world_matrix(true) * shift;
|
Vec3d i_shift = i->world_matrix(true) * shift;
|
||||||
i->offset -= to_2d(i_shift);
|
i->offset -= to_2d(i_shift);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
@ -1004,8 +1039,13 @@ BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mes
|
|||||||
}
|
}
|
||||||
// Translate the bounding box.
|
// Translate the bounding box.
|
||||||
if (! dont_translate) {
|
if (! dont_translate) {
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
bbox.min += this->m_offset;
|
||||||
|
bbox.max += this->m_offset;
|
||||||
|
#else
|
||||||
Eigen::Map<Vec2d>(bbox.min.data()) += this->offset;
|
Eigen::Map<Vec2d>(bbox.min.data()) += this->offset;
|
||||||
Eigen::Map<Vec2d>(bbox.max.data()) += this->offset;
|
Eigen::Map<Vec2d>(bbox.max.data()) += this->offset;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bbox;
|
return bbox;
|
||||||
@ -1032,7 +1072,11 @@ Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, b
|
|||||||
Transform3d m = Transform3d::Identity();
|
Transform3d m = Transform3d::Identity();
|
||||||
|
|
||||||
if (!dont_translate)
|
if (!dont_translate)
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
m.translate(m_offset);
|
||||||
|
#else
|
||||||
m.translate(Vec3d(offset(0), offset(1), 0.0));
|
m.translate(Vec3d(offset(0), offset(1), 0.0));
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
if (!dont_rotate)
|
if (!dont_rotate)
|
||||||
m.rotate(Eigen::AngleAxisd(rotation, Vec3d::UnitZ()));
|
m.rotate(Eigen::AngleAxisd(rotation, Vec3d::UnitZ()));
|
||||||
|
@ -224,15 +224,32 @@ public:
|
|||||||
|
|
||||||
friend class ModelObject;
|
friend class ModelObject;
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
private:
|
||||||
|
Vec3d m_offset; // in unscaled coordinates
|
||||||
|
|
||||||
|
public:
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
double rotation; // Rotation around the Z axis, in radians around mesh center point
|
double rotation; // Rotation around the Z axis, in radians around mesh center point
|
||||||
double scaling_factor;
|
double scaling_factor;
|
||||||
|
#if !ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
Vec2d offset; // in unscaled coordinates
|
Vec2d offset; // in unscaled coordinates
|
||||||
|
#endif // !ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
// flag showing the position of this instance with respect to the print volume (set by Print::validate() using ModelObject::check_instances_print_volume_state())
|
// flag showing the position of this instance with respect to the print volume (set by Print::validate() using ModelObject::check_instances_print_volume_state())
|
||||||
EPrintVolumeState print_volume_state;
|
EPrintVolumeState print_volume_state;
|
||||||
|
|
||||||
ModelObject* get_object() const { return this->object; }
|
ModelObject* get_object() const { return this->object; }
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
const Vec3d& get_offset() const { return m_offset; }
|
||||||
|
double get_offset(Axis axis) const { return m_offset(axis); }
|
||||||
|
|
||||||
|
void set_offset(const Vec3d& offset) { m_offset = offset; }
|
||||||
|
void set_offset(Axis axis, double offset) { m_offset(axis) = offset; }
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
// To be called on an external mesh
|
// To be called on an external mesh
|
||||||
void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const;
|
void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const;
|
||||||
// Calculate a bounding box of a transformed mesh. To be called on an external mesh.
|
// Calculate a bounding box of a transformed mesh. To be called on an external mesh.
|
||||||
@ -252,9 +269,15 @@ private:
|
|||||||
// Parent object, owning this instance.
|
// Parent object, owning this instance.
|
||||||
ModelObject* object;
|
ModelObject* object;
|
||||||
|
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), m_offset(Vec3d::Zero()), object(object), print_volume_state(PVS_Inside) {}
|
||||||
|
ModelInstance(ModelObject *object, const ModelInstance &other) :
|
||||||
|
rotation(other.rotation), scaling_factor(other.scaling_factor), m_offset(other.m_offset), object(object), print_volume_state(PVS_Inside) {}
|
||||||
|
#else
|
||||||
ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), offset(Vec2d::Zero()), object(object), print_volume_state(PVS_Inside) {}
|
ModelInstance(ModelObject *object) : rotation(0), scaling_factor(1), offset(Vec2d::Zero()), object(object), print_volume_state(PVS_Inside) {}
|
||||||
ModelInstance(ModelObject *object, const ModelInstance &other) :
|
ModelInstance(ModelObject *object, const ModelInstance &other) :
|
||||||
rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object), print_volume_state(PVS_Inside) {}
|
rotation(other.rotation), scaling_factor(other.scaling_factor), offset(other.offset), object(object), print_volume_state(PVS_Inside) {}
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -517,8 +517,13 @@ ShapeData2D projectModelFromTop(const Slic3r::Model &model) {
|
|||||||
if(item.vertexCount() > 3) {
|
if(item.vertexCount() > 3) {
|
||||||
item.rotation(objinst->rotation);
|
item.rotation(objinst->rotation);
|
||||||
item.translation( {
|
item.translation( {
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
ClipperLib::cInt(objinst->get_offset(X) / SCALING_FACTOR),
|
||||||
|
ClipperLib::cInt(objinst->get_offset(Y) / SCALING_FACTOR)
|
||||||
|
#else
|
||||||
ClipperLib::cInt(objinst->offset(0)/SCALING_FACTOR),
|
ClipperLib::cInt(objinst->offset(0)/SCALING_FACTOR),
|
||||||
ClipperLib::cInt(objinst->offset(1)/SCALING_FACTOR)
|
ClipperLib::cInt(objinst->offset(1)/SCALING_FACTOR)
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
});
|
});
|
||||||
ret.emplace_back(objinst, item);
|
ret.emplace_back(objinst, item);
|
||||||
}
|
}
|
||||||
@ -655,11 +660,19 @@ void applyResult(
|
|||||||
// appropriately
|
// appropriately
|
||||||
auto off = item.translation();
|
auto off = item.translation();
|
||||||
Radians rot = item.rotation();
|
Radians rot = item.rotation();
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec3d foff(off.X*SCALING_FACTOR + batch_offset, off.Y*SCALING_FACTOR, 0.0);
|
||||||
|
#else
|
||||||
Vec2d foff(off.X*SCALING_FACTOR + batch_offset, off.Y*SCALING_FACTOR);
|
Vec2d foff(off.X*SCALING_FACTOR + batch_offset, off.Y*SCALING_FACTOR);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
// write the tranformation data into the model instance
|
// write the tranformation data into the model instance
|
||||||
inst_ptr->rotation = rot;
|
inst_ptr->rotation = rot;
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
inst_ptr->set_offset(foff);
|
||||||
|
#else
|
||||||
inst_ptr->offset = foff;
|
inst_ptr->offset = foff;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +102,16 @@ bool PrintObject::reload_model_instances()
|
|||||||
copies.reserve(this->_model_object->instances.size());
|
copies.reserve(this->_model_object->instances.size());
|
||||||
for (const ModelInstance *mi : this->_model_object->instances)
|
for (const ModelInstance *mi : this->_model_object->instances)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
if (mi->is_printable())
|
||||||
|
{
|
||||||
|
const Vec3d& offset = mi->get_offset();
|
||||||
|
copies.emplace_back(Point::new_scale(offset(0), offset(1)));
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (mi->is_printable())
|
if (mi->is_printable())
|
||||||
copies.emplace_back(Point::new_scale(mi->offset(0), mi->offset(1)));
|
copies.emplace_back(Point::new_scale(mi->offset(0), mi->offset(1)));
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
return this->set_copies(copies);
|
return this->set_copies(copies);
|
||||||
}
|
}
|
||||||
|
12
xs/src/libslic3r/Technologies.hpp
Normal file
12
xs/src/libslic3r/Technologies.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef _technologies_h_
|
||||||
|
#define _technologies_h_
|
||||||
|
|
||||||
|
// 1.42.0 techs
|
||||||
|
#define ENABLE_1_42_0 1
|
||||||
|
|
||||||
|
// Add z coordinate to model instances' offset
|
||||||
|
#define ENABLE_MODELINSTANCE_3D_OFFSET (1 && ENABLE_1_42_0)
|
||||||
|
|
||||||
|
#endif // _technologies_h_
|
||||||
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
|
#include "Technologies.hpp"
|
||||||
|
|
||||||
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
|
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
|
||||||
#define SLIC3R_VERSION "1.41.0"
|
#define SLIC3R_VERSION "1.41.0"
|
||||||
#define SLIC3R_BUILD "UNKNOWN"
|
#define SLIC3R_BUILD "UNKNOWN"
|
||||||
|
@ -684,7 +684,11 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||||||
}
|
}
|
||||||
v.is_modifier = model_volume->modifier;
|
v.is_modifier = model_volume->modifier;
|
||||||
v.shader_outside_printer_detection_enabled = !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));
|
v.set_offset(Vec3d(instance->offset(0), instance->offset(1), 0.0));
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
v.set_rotation(instance->rotation);
|
v.set_rotation(instance->rotation);
|
||||||
v.set_scaling_factor(instance->scaling_factor);
|
v.set_scaling_factor(instance->scaling_factor);
|
||||||
}
|
}
|
||||||
|
@ -1140,8 +1140,10 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
|
|||||||
if (!gizmo->init())
|
if (!gizmo->init())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if !ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
// temporary disable z grabber
|
// temporary disable z grabber
|
||||||
gizmo->disable_grabber(2);
|
gizmo->disable_grabber(2);
|
||||||
|
#endif // !ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
|
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
|
||||||
|
|
||||||
@ -2375,7 +2377,11 @@ void GLCanvas3D::update_gizmos_data()
|
|||||||
ModelInstance* model_instance = model_object->instances[0];
|
ModelInstance* model_instance = model_object->instances[0];
|
||||||
if (model_instance != nullptr)
|
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));
|
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_scale(model_instance->scaling_factor);
|
||||||
m_gizmos.set_angle_z(model_instance->rotation);
|
m_gizmos.set_angle_z(model_instance->rotation);
|
||||||
m_gizmos.set_flattening_data(model_object);
|
m_gizmos.set_flattening_data(model_object);
|
||||||
@ -5360,8 +5366,12 @@ void GLCanvas3D::_on_move(const std::vector<int>& volume_idxs)
|
|||||||
ModelObject* model_object = m_model->objects[obj_idx];
|
ModelObject* model_object = m_model->objects[obj_idx];
|
||||||
if (model_object != nullptr)
|
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();
|
const Vec3d& offset = volume->get_offset();
|
||||||
model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1));
|
model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1));
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
model_object->invalidate_bounding_box();
|
model_object->invalidate_bounding_box();
|
||||||
update_position_values();
|
update_position_values();
|
||||||
object_moved = true;
|
object_moved = true;
|
||||||
|
@ -1032,6 +1032,7 @@ GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent)
|
|||||||
, m_position(Vec3d::Zero())
|
, m_position(Vec3d::Zero())
|
||||||
, m_starting_drag_position(Vec3d::Zero())
|
, m_starting_drag_position(Vec3d::Zero())
|
||||||
, m_starting_box_center(Vec3d::Zero())
|
, m_starting_box_center(Vec3d::Zero())
|
||||||
|
, m_starting_box_bottom_center(Vec3d::Zero())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1065,17 +1066,19 @@ void GLGizmoMove3D::on_start_dragging(const BoundingBoxf3& box)
|
|||||||
{
|
{
|
||||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||||
m_starting_box_center = box.center();
|
m_starting_box_center = box.center();
|
||||||
|
m_starting_box_bottom_center = box.center();
|
||||||
|
m_starting_box_bottom_center(2) = box.min(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoMove3D::on_update(const Linef3& mouse_ray)
|
void GLGizmoMove3D::on_update(const Linef3& mouse_ray)
|
||||||
{
|
{
|
||||||
if (m_hover_id == 0)
|
if (m_hover_id == 0)
|
||||||
m_position(0) = 2.0 * m_starting_box_center(0) + calc_displacement(1, mouse_ray) - m_starting_drag_position(0);
|
m_position(0) = 2.0 * m_starting_box_center(0) + calc_projection(X, 1, mouse_ray) - m_starting_drag_position(0);
|
||||||
else if (m_hover_id == 1)
|
else if (m_hover_id == 1)
|
||||||
m_position(1) = 2.0 * m_starting_box_center(1) + calc_displacement(2, mouse_ray) - m_starting_drag_position(1);
|
m_position(1) = 2.0 * m_starting_box_center(1) + calc_projection(Y, 2, mouse_ray) - m_starting_drag_position(1);
|
||||||
else if (m_hover_id == 2)
|
else if (m_hover_id == 2)
|
||||||
m_position(2) = 2.0 * m_starting_box_center(2) + calc_displacement(1, mouse_ray) - m_starting_drag_position(2);
|
m_position(2) = 2.0 * m_starting_box_bottom_center(2) + calc_projection(Z, 1, mouse_ray) - m_starting_drag_position(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||||
@ -1144,40 +1147,40 @@ void GLGizmoMove3D::on_render_for_picking(const BoundingBoxf3& box) const
|
|||||||
render_grabbers_for_picking(box);
|
render_grabbers_for_picking(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
double GLGizmoMove3D::calc_displacement(unsigned int preferred_plane_id, const Linef3& mouse_ray) const
|
double GLGizmoMove3D::calc_projection(Axis axis, unsigned int preferred_plane_id, const Linef3& mouse_ray) const
|
||||||
{
|
{
|
||||||
double displacement = 0.0;
|
double projection = 0.0;
|
||||||
|
|
||||||
Vec3d starting_vec = m_starting_drag_position - m_starting_box_center;
|
Vec3d starting_vec = (axis == Z) ? m_starting_drag_position - m_starting_box_bottom_center : m_starting_drag_position - m_starting_box_center;
|
||||||
double len_starting_vec = starting_vec.norm();
|
double len_starting_vec = starting_vec.norm();
|
||||||
if (len_starting_vec == 0.0)
|
if (len_starting_vec == 0.0)
|
||||||
return displacement;
|
return projection;
|
||||||
|
|
||||||
Vec3d starting_vec_dir = starting_vec.normalized();
|
Vec3d starting_vec_dir = starting_vec.normalized();
|
||||||
Vec3d mouse_dir = mouse_ray.unit_vector();
|
Vec3d mouse_dir = mouse_ray.unit_vector();
|
||||||
|
|
||||||
unsigned int plane_id = select_best_plane(mouse_dir, preferred_plane_id);
|
unsigned int plane_id = select_best_plane(mouse_dir, preferred_plane_id);
|
||||||
|
|
||||||
switch (plane_id)
|
switch (plane_id)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
displacement = starting_vec_dir.dot(intersection_on_plane_xy(mouse_ray, m_starting_box_center));
|
projection = starting_vec_dir.dot(intersection_on_plane_xy(mouse_ray, (axis == Z) ? m_starting_box_bottom_center : m_starting_box_center));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
displacement = starting_vec_dir.dot(intersection_on_plane_xz(mouse_ray, m_starting_box_center));
|
projection = starting_vec_dir.dot(intersection_on_plane_xz(mouse_ray, (axis == Z) ? m_starting_box_bottom_center : m_starting_box_center));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
displacement = starting_vec_dir.dot(intersection_on_plane_yz(mouse_ray, m_starting_box_center));
|
projection = starting_vec_dir.dot(intersection_on_plane_yz(mouse_ray, (axis == Z) ? m_starting_box_bottom_center : m_starting_box_center));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return displacement;
|
return projection;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent)
|
GLGizmoFlatten::GLGizmoFlatten(GLCanvas3D& parent)
|
||||||
@ -1233,10 +1236,19 @@ void GLGizmoFlatten::on_render(const BoundingBoxf3& box) const
|
|||||||
else
|
else
|
||||||
::glColor4f(0.9f, 0.9f, 0.9f, 0.5f);
|
::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) {
|
for (Vec2d offset : m_instances_positions) {
|
||||||
offset += to_2d(dragged_offset);
|
offset += to_2d(dragged_offset);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
::glTranslated(offset(0), offset(1), offset(2));
|
||||||
|
#else
|
||||||
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
|
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
::glBegin(GL_POLYGON);
|
::glBegin(GL_POLYGON);
|
||||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||||
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
||||||
@ -1255,9 +1267,17 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const
|
|||||||
for (unsigned int i = 0; i < m_planes.size(); ++i)
|
for (unsigned int i = 0; i < m_planes.size(); ++i)
|
||||||
{
|
{
|
||||||
::glColor3f(1.0f, 1.0f, picking_color_component(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) {
|
for (const Vec2d& offset : m_instances_positions) {
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
::glPushMatrix();
|
::glPushMatrix();
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
::glTranslated(offset(0), offset(1), offset(2));
|
||||||
|
#else
|
||||||
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
|
::glTranslatef((GLfloat)offset(0), (GLfloat)offset(1), 0.0f);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
::glBegin(GL_POLYGON);
|
::glBegin(GL_POLYGON);
|
||||||
for (const Vec3d& vertex : m_planes[i].vertices)
|
for (const Vec3d& vertex : m_planes[i].vertices)
|
||||||
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
::glVertex3f((GLfloat)vertex(0), (GLfloat)vertex(1), (GLfloat)vertex(2));
|
||||||
@ -1275,7 +1295,11 @@ void GLGizmoFlatten::set_flattening_data(const ModelObject* model_object)
|
|||||||
if (m_model_object && !m_model_object->instances.empty()) {
|
if (m_model_object && !m_model_object->instances.empty()) {
|
||||||
m_instances_positions.clear();
|
m_instances_positions.clear();
|
||||||
for (const auto* instance : m_model_object->instances)
|
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);
|
m_instances_positions.emplace_back(instance->offset);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_plane_update_necessary())
|
if (is_plane_update_necessary())
|
||||||
|
@ -287,6 +287,7 @@ class GLGizmoMove3D : public GLGizmoBase
|
|||||||
Vec3d m_position;
|
Vec3d m_position;
|
||||||
Vec3d m_starting_drag_position;
|
Vec3d m_starting_drag_position;
|
||||||
Vec3d m_starting_box_center;
|
Vec3d m_starting_box_center;
|
||||||
|
Vec3d m_starting_box_bottom_center;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GLGizmoMove3D(GLCanvas3D& parent);
|
explicit GLGizmoMove3D(GLCanvas3D& parent);
|
||||||
@ -302,7 +303,7 @@ protected:
|
|||||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double calc_displacement(unsigned int preferred_plane_id, const Linef3& mouse_ray) const;
|
double calc_projection(Axis axis, unsigned int preferred_plane_id, const Linef3& mouse_ray) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLGizmoFlatten : public GLGizmoBase
|
class GLGizmoFlatten : public GLGizmoBase
|
||||||
@ -328,7 +329,11 @@ private:
|
|||||||
SourceDataSummary m_source_data;
|
SourceDataSummary m_source_data;
|
||||||
|
|
||||||
std::vector<PlaneData> m_planes;
|
std::vector<PlaneData> m_planes;
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Pointf3s m_instances_positions;
|
||||||
|
#else
|
||||||
std::vector<Vec2d> m_instances_positions;
|
std::vector<Vec2d> m_instances_positions;
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
Vec3d m_starting_center;
|
Vec3d m_starting_center;
|
||||||
const ModelObject* m_model_object = nullptr;
|
const ModelObject* m_model_object = nullptr;
|
||||||
|
|
||||||
|
@ -1771,9 +1771,15 @@ void update_position_values()
|
|||||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||||
auto instance = (*m_objects)[m_selected_object_id]->instances.front();
|
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_x", int(instance->offset(0)));
|
||||||
og->set_value("position_y", int(instance->offset(1)));
|
og->set_value("position_y", int(instance->offset(1)));
|
||||||
og->set_value("position_z", 0);
|
og->set_value("position_z", 0);
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_position_values(const Vec3d& position)
|
void update_position_values(const Vec3d& position)
|
||||||
|
@ -358,15 +358,28 @@ ModelMaterial::attributes()
|
|||||||
%code%{ RETVAL = THIS->rotation; %};
|
%code%{ RETVAL = THIS->rotation; %};
|
||||||
double scaling_factor()
|
double scaling_factor()
|
||||||
%code%{ RETVAL = THIS->scaling_factor; %};
|
%code%{ RETVAL = THIS->scaling_factor; %};
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
Vec2d* offset()
|
||||||
|
%code%{ RETVAL = new Vec2d(THIS->get_offset(X), THIS->get_offset(Y)); %};
|
||||||
|
#else
|
||||||
Ref<Vec2d> offset()
|
Ref<Vec2d> offset()
|
||||||
%code%{ RETVAL = &THIS->offset; %};
|
%code%{ RETVAL = &THIS->offset; %};
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
void set_rotation(double val)
|
void set_rotation(double val)
|
||||||
%code%{ THIS->rotation = val; THIS->get_object()->invalidate_bounding_box(); %};
|
%code%{ THIS->rotation = val; THIS->get_object()->invalidate_bounding_box(); %};
|
||||||
void set_scaling_factor(double val)
|
void set_scaling_factor(double val)
|
||||||
%code%{ THIS->scaling_factor = val; THIS->get_object()->invalidate_bounding_box(); %};
|
%code%{ THIS->scaling_factor = val; THIS->get_object()->invalidate_bounding_box(); %};
|
||||||
|
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
void set_offset(Vec2d *offset)
|
||||||
|
%code%{
|
||||||
|
THIS->set_offset(X, (*offset)(0));
|
||||||
|
THIS->set_offset(Y, (*offset)(1));
|
||||||
|
%};
|
||||||
|
#else
|
||||||
void set_offset(Vec2d *offset)
|
void set_offset(Vec2d *offset)
|
||||||
%code%{ THIS->offset = *offset; %};
|
%code%{ THIS->offset = *offset; %};
|
||||||
|
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||||
|
|
||||||
void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const;
|
void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const;
|
||||||
void transform_polygon(Polygon* polygon) const;
|
void transform_polygon(Polygon* polygon) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user