Skip to content

Commit

Permalink
transform: simplify transform matrix parsing (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
nianjiuhuiyi authored Jul 13, 2023
1 parent d2d874d commit 5347df2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions apps/TransformScene/TransformScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,18 @@ int main(int argc, LPCTSTR* argv)
if (!OPT::strTransformFileName.empty()) {
// transform this scene by the given transform matrix
std::ifstream file(MAKE_PATH_SAFE(OPT::strTransformFileName));
std::string strLine;
std::string value;
std::vector<double> transformValues;
while (std::getline(file, strLine)) {
errno = 0;
char* strEnd{};
const double v = std::strtod(strLine.c_str(), &strEnd);
if (errno == ERANGE || strEnd == strLine.c_str())
continue;
transformValues.push_back(v);
}
while (file >> value) {
double v;
try {
v = std::stod(value);
}
catch (...) {
continue;
}
transformValues.push_back(v);
}
if (transformValues.size() != 12 &&
(transformValues.size() != 16 || transformValues[12] != 0 || transformValues[13] != 0 || transformValues[14] != 0 || transformValues[15] != 1)) {
VERBOSE("error: invalid transform");
Expand Down

0 comments on commit 5347df2

Please sign in to comment.