Selection Design

From K-3D

Jump to: navigation, search


A selectable object is one that implements the k3d::iselectable interface, defined in k3dsdk/iselectable.h.

The k3d::iselectable interface provides methods to get-and-set a selection weight, which stores the selected state of an object. A selection weight of 0.0 is "not selected", any other value is "selected". Typically, selected objects will have a selection weight of 1.0, but any weight is allowed, including negative values and values less-than or greater-than 1.0.

  • For all-or-nothing operations (such as SetMaterial or Delete), the selection weight is interpeted as a boolean, where 0.0 = false and any other value = true.
  • Other operations (such as point deformations) use selection weight to perform linear interpolation between modified and unmodified values. Thus selection weight can be used to provide "soft" selections, invert the behavior of a deformation, or scale its effect.


Mesh-selection (properties of type "k3d::mesh_selection") is a tri-state, meaning that you can explicitly select, explicitly deselect, or explicitly ignore the selection state of a mesh component at different points in the pipeline.

There is room for improvement, k3d::mesh_selection stores ranges of selection weights, but we aren't taking full advantage of it yet. If you take a look at k3d::mesh_selection::insert(), you will see that it is a naive implementation that just inserts individual records into the selection, without consolidating ranges. A more sophisticated implementation that consolidates adjacent ranges of identical weights will reduce file size while retaining forwards and backwards compatibility.

Personal tools