Skip to content

Commit 577d27f

Browse files
committed
intersect(if_non_empty=)
1 parent 68c70c4 commit 577d27f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

voxec.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1374,12 +1374,15 @@ template <abstract_voxel_storage*(abstract_voxel_storage::*Fn)(const abstract_vo
13741374
class op_boolean : public voxel_operation {
13751375
public:
13761376
const std::vector<argument_spec>& arg_names() const {
1377-
static std::vector<argument_spec> nm_ = { { true, "a", "voxels" }, { true, "b", "voxels" } };
1377+
static std::vector<argument_spec> nm_ = { { true, "a", "voxels" }, { true, "b", "voxels" }, {false, "if_non_empty", "integer"} };
13781378
return nm_;
13791379
}
13801380
symbol_value invoke(const scope_map& scope) const {
13811381
abstract_voxel_storage* a = scope.get_value<abstract_voxel_storage*>("a");
13821382
abstract_voxel_storage* b = scope.get_value<abstract_voxel_storage*>("b");
1383+
if (scope.get_value_or<int>("if_non_empty", 0) == 1 && b->count() == 0) {
1384+
return a;
1385+
}
13831386
return (a->*Fn)(b);
13841387
}
13851388
};

0 commit comments

Comments
 (0)