Part one of refactor of LS.ckint/LS.tryint/LS.isint
This commit is contained in:
@@ -835,34 +835,35 @@ void PlaneScan::configure(LuaKeywordParser &kp) {
|
||||
bool have_near = false;
|
||||
|
||||
if (kp.parse(val, "plane")) {
|
||||
LS.checkstring(val, "plane");
|
||||
plane_ = LS.ckstring(val);
|
||||
plane_ = LS.ckstring(val, "plane");
|
||||
have_plane = true;
|
||||
}
|
||||
|
||||
if (kp.parse(val, "center")) {
|
||||
LS.checkxyz(val, "center");
|
||||
util::DXYZ xyz = LS.ckxyz(val);
|
||||
util::DXYZ xyz = LS.ckxyz(val, "center");
|
||||
center_ = xyz;
|
||||
have_center = true;
|
||||
}
|
||||
|
||||
if (kp.parse(val, "radius")) {
|
||||
if (LS.isnumber(val)) {
|
||||
radius_.x = LS.cknumber(val);
|
||||
radius_.y = radius_.z = radius_.x;
|
||||
auto simple = LS.trynumber(val);
|
||||
if (simple) {
|
||||
radius_ = *simple;
|
||||
have_radius = true;
|
||||
} else {
|
||||
LS.checkxyz(val, "radius");
|
||||
util::DXYZ xyz = LS.ckxyz(val);
|
||||
radius_ = xyz;
|
||||
have_radius = true;
|
||||
auto full = LS.tryxyz(val);
|
||||
if (full) {
|
||||
radius_ = *full;
|
||||
have_radius = true;
|
||||
}
|
||||
}
|
||||
if (!have_radius) {
|
||||
luaL_error(L, "scan configuration: 'radius' must be a vector or number");
|
||||
}
|
||||
}
|
||||
|
||||
if (kp.parse(val, "shape")) {
|
||||
LS.checkstring(val, "shape");
|
||||
eng::string shape = LS.ckstring(val);
|
||||
eng::string shape = LS.ckstring(val, "shape");
|
||||
if (shape == "box") {
|
||||
shape_ = BOX;
|
||||
} else if (shape == "sphere") {
|
||||
@@ -893,19 +894,17 @@ void PlaneScan::configure(LuaKeywordParser &kp) {
|
||||
}
|
||||
|
||||
if (kp.parse(val, "include")) {
|
||||
LS.checkboolean(val, "include");
|
||||
if (!have_near) {
|
||||
luaL_error(L, "scan configuration: 'include' specified without 'near'");
|
||||
}
|
||||
include_near_ = LS.ckboolean(val);
|
||||
include_near_ = LS.ckboolean(val, "include");
|
||||
}
|
||||
|
||||
if (kp.parse(val, "wholeplane")) {
|
||||
LS.checkstring(val, "wholeplane");
|
||||
if (have_plane || have_center || have_radius || have_shape) {
|
||||
luaL_error(L, "scan configuration: do not specify plane, center, shape, or radius with 'wholeplane'");
|
||||
}
|
||||
plane_ = LS.ckstring(val);
|
||||
plane_ = LS.ckstring(val, "wholeplane");
|
||||
set_whole_plane();
|
||||
have_plane = true;
|
||||
have_center = true;
|
||||
|
||||
Reference in New Issue
Block a user