#791 Handle twist=0 as no twist

master
Marius Kintel 2014-05-19 11:49:41 -04:00
parent 13d46e994e
commit e4dd4da818
3 changed files with 22 additions and 20 deletions

View File

@ -110,13 +110,15 @@ AbstractNode *LinearExtrudeModule::instantiate(const Context *ctx, const ModuleI
if (twist.type() == Value::NUMBER) {
node->twist = twist.toDouble();
if (slices.type() == Value::NUMBER) {
node->slices = (int)slices.toDouble();
} else {
node->slices = (int)fmax(2, fabs(Calc::get_fragments_from_r(node->height,
node->fn, node->fs, node->fa) * node->twist / 360));
if (node->twist != 0.0) {
if (slices.type() == Value::NUMBER) {
node->slices = (int)slices.toDouble();
} else {
node->slices = (int)fmax(2, fabs(Calc::get_fragments_from_r(node->height,
node->fn, node->fs, node->fa) * node->twist / 360));
}
node->has_twist = true;
}
node->has_twist = true;
}
if (node->filename.empty()) {

View File

@ -2,7 +2,7 @@ group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
difference() {
square(size = [2, 2], center = true);
square(size = [1, 1], center = true);
@ -10,7 +10,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
multmatrix([[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1, 1], center = true);
}
@ -20,7 +20,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 8], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
multmatrix([[1, 0, 0, 0.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1, 1], center = false);
}
@ -30,7 +30,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 12], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 1], $fn = 0, $fa = 12, $fs = 2) {
difference() {
square(size = [2, 2], center = true);
multmatrix([[1, 0, 0, -0.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
@ -44,7 +44,7 @@ group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 3], [0, 0, 1, 0], [0, 0, 0, 1]]) {
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
difference() {
square(size = [2, 2], center = true);
square(size = [1, 1], center = true);
@ -52,7 +52,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
multmatrix([[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1, 1], center = true);
}
@ -62,7 +62,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 8], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
multmatrix([[1, 0, 0, 0.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1, 1], center = false);
}
@ -72,7 +72,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 12], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [1, 0], $fn = 0, $fa = 12, $fs = 2) {
difference() {
square(size = [2, 2], center = true);
multmatrix([[1, 0, 0, -0.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
@ -86,7 +86,7 @@ group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 6], [0, 0, 1, 0], [0, 0, 0, 1]]) {
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
difference() {
square(size = [2, 2], center = true);
square(size = [1, 1], center = true);
@ -94,7 +94,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 4], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
multmatrix([[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1, 1], center = true);
}
@ -104,7 +104,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 8], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
multmatrix([[1, 0, 0, 0.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
square(size = [1, 1], center = false);
}
@ -114,7 +114,7 @@ group() {
}
}
multmatrix([[1, 0, 0, 12], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
linear_extrude(height = 3, center = false, convexity = 1, twist = 0, slices = 20, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 3, center = false, convexity = 1, scale = [0, 0], $fn = 0, $fa = 12, $fs = 2) {
difference() {
square(size = [2, 2], center = true);
multmatrix([[1, 0, 0, -0.5], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {

View File

@ -40,10 +40,10 @@ group() {
group() {
multmatrix([[0, 0, 1, 0], [0, 1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 1]]) {
union() {
linear_extrude(height = 1.5, center = true, convexity = 1, twist = 0, slices = 2, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 1.5, center = true, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) {
circle($fn = 30, $fa = 12, $fs = 2, r = 0.3);
}
linear_extrude(height = 1.5, center = true, convexity = 1, twist = 0, slices = 2, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) {
linear_extrude(height = 1.5, center = true, convexity = 1, scale = [1, 1], $fn = 0, $fa = 12, $fs = 2) {
projection(cut = false, convexity = 0) {
multmatrix([[0, 0, -1, 0], [0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1]]) {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0.31819805153], [0, 0, 0, 1]]) {