mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-28 07:49:45 +00:00
add ghosting
This commit is contained in:
parent
f982b96d12
commit
1930d5deee
2 changed files with 71 additions and 24 deletions
|
@ -39,7 +39,9 @@ $edge_length = undef;
|
|||
$tags_shown = "ALL";
|
||||
$tags_hidden = [];
|
||||
|
||||
|
||||
$ghost_this=false;
|
||||
$ghost=false;
|
||||
$ghosting=false; // Ghosting is in effect, so don't apply it again
|
||||
|
||||
_ANCHOR_TYPES = ["intersect","hull"];
|
||||
|
||||
|
@ -3070,7 +3072,7 @@ module attachable(
|
|||
axis=UP,override,
|
||||
geom,
|
||||
expose_tags=false, keep_color=false
|
||||
) {
|
||||
) {
|
||||
dummy1 =
|
||||
assert($children==2, "attachable() expects exactly two children; the shape to manage, and the union of all attachment candidates.")
|
||||
assert(is_undef(anchor) || is_vector(anchor) || is_string(anchor), str("Invalid anchor: ",anchor))
|
||||
|
@ -3104,31 +3106,32 @@ module attachable(
|
|||
$attach_alignment=undef;
|
||||
if (expose_tags || _is_shown()){
|
||||
if (!keep_color)
|
||||
_color($color) children(0);
|
||||
_color($color)
|
||||
if (($ghost || $ghost_this) && !$ghosting)
|
||||
%union(){
|
||||
$ghosting=true;
|
||||
children(0);
|
||||
}
|
||||
else children(0);
|
||||
else {
|
||||
$save_color=undef; // Force color_this() color in effect to persist for the entire object
|
||||
children(0);
|
||||
if (($ghost || $ghost_this) && !$ghosting)
|
||||
%union(){
|
||||
$ghosting=true;
|
||||
children(0);
|
||||
}
|
||||
else children(0);
|
||||
}
|
||||
}
|
||||
if (is_def($save_tag) && is_def($save_color)){
|
||||
$tag=$save_tag;
|
||||
$save_tag=undef;
|
||||
$color=$save_color; // Revert to the color before color_this() call
|
||||
$save_color=undef;
|
||||
children(1);
|
||||
}
|
||||
else if (is_def($save_color)) {
|
||||
$color=$save_color; // Revert to the color before color_this() call
|
||||
$save_color=undef;
|
||||
children(1);
|
||||
}
|
||||
else if (is_def($save_tag)) {
|
||||
$tag=$save_tag;
|
||||
$save_tag=undef;
|
||||
children(1);
|
||||
}
|
||||
else children(1);
|
||||
}
|
||||
let(
|
||||
$ghost_this=false,
|
||||
$tag=default($save_tag,$tag),
|
||||
$save_tag=undef,
|
||||
$color=default($save_color,$color),
|
||||
$save_color=undef
|
||||
)
|
||||
children(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Function: reorient()
|
||||
|
@ -3926,7 +3929,7 @@ function _find_anchor(anchor, geom)=
|
|||
: oang // face anchors point UP/BACK
|
||||
) [anchor, final_pos, final_dir, default(override[2],spin),
|
||||
if (is_def(edgeang)) [["edge_angle",edgeang],["edge_length",edgelen], ["vec", endvecs]]]
|
||||
) : type == "conoid"? ( //r1, r2, l, shift
|
||||
) : type == "conoid"? ( //r1, r2, l, shift, axis
|
||||
let(
|
||||
rr1=geom[1],
|
||||
rr2=geom[2],
|
||||
|
|
44
color.scad
44
color.scad
|
@ -161,6 +161,50 @@ module color_overlaps(color="red") {
|
|||
%children();
|
||||
}
|
||||
|
||||
// Module: ghost()
|
||||
// Synopsis: Sets transparency for attachable children and their descendents.
|
||||
// SynTags: Trans
|
||||
// Topics: Attachments
|
||||
// See Also: ghost_this(), recolor(), color_this()
|
||||
// Usage:
|
||||
// ghost([ghost]) CHILDREN;
|
||||
// Description:
|
||||
// Sets the transparency for the attachable children and their descendents until another {{ghost()}} or {{ghost_this()}}.
|
||||
// By default, turns transparency on. Give the `false` parameter to disable transparency.
|
||||
// Do not mix this with user supplied `%` operators anywhere in the geometry tree.
|
||||
// Arguments:
|
||||
// ghost = If true set the descendents to be transparent; if false, disable transparency. Default: true
|
||||
// Example(3D):
|
||||
// ghost() cuboid(10)
|
||||
// ghost(false) cuboid(5);
|
||||
function ghost(ghost) = no_function("ghost");
|
||||
module ghost(ghost=true)
|
||||
{
|
||||
$ghost=ghost;
|
||||
children();
|
||||
}
|
||||
|
||||
|
||||
// Module: ghost_this()
|
||||
// Synopsis: Makes the children at a single level transparent.
|
||||
// SynTags: Trans
|
||||
// Topics: Attachments
|
||||
// See Also: ghost(), recolor(), color_this()
|
||||
// Usage:
|
||||
// ghost_this() CHILDREN;
|
||||
// Description:
|
||||
// Makes the children transparent for one level, reverting to the previous transparency state for further descendents.
|
||||
// This works only with attachables and you cannot give the `%` operator anywhere in the geometry tree.
|
||||
// Example(3D):
|
||||
// ghost_this() cuboid(10)
|
||||
// cuboid(5);
|
||||
function ghost_this() = no_function("ghost_this");
|
||||
module ghost_this()
|
||||
{
|
||||
$ghost_this=true;
|
||||
children();
|
||||
}
|
||||
|
||||
|
||||
// Section: Colorspace Conversion
|
||||
|
||||
|
|
Loading…
Reference in a new issue