Repository navigation
fixed several isses in vdb_tool - #2349
Conversation
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
Signed-off-by: Ken Museth <ken.museth@gmail.com>
swahtz
left a comment
There was a problem hiding this comment.
A few comments that would clean up or address some small gotchyas. I think the one issue that's definitely blocking is the change in round-trip half grid behaviour in writeVDB by calling setSaveFloatAsHalf for every grid.
| GridPtrVec output; | ||
| for (const auto &grid : grids) { | ||
| output.push_back(grid->copyGrid()); | ||
| output.back()->setSaveFloatAsHalf(half); |
There was a problem hiding this comment.
🚩 issue: Because setSaveFloatAsHalf is called for every grid, this changes behaviour for round-tripping half grids. -read half.vdb -write out.vdb used to round-trip as 16-bit. With this PR, because bits=32 is the default, it silently writes 32-bit instead of preserving the half grid.
|
|
||
| } catch (const std::exception& e) { | ||
|
|
||
| std::cerr << "Fatal error in " << argv[0] << ":\n\t" << e.what() << std::endl; |
There was a problem hiding this comment.
💭 thought (non-blocking): I don't know if it is intended behavior or not, but fatal errors like this are no longer going to reach the -log file. The exception unwinds and destroys Tool, whose destructor calls endLog(), before main prints the message. With tee=false, the log has no record of why the run failed.
| if (sum < std::numeric_limits<T>::lowest() || sum > std::numeric_limits<T>::max()) | ||
| throw std::invalid_argument("ForLoop: loop value out of range"); | ||
| const T next = static_cast<T>(sum); | ||
| if (vec[2] > T(0) ? next <= vec[0] : next >= vec[0]) |
There was a problem hiding this comment.
🎵 note (non-blocking): The "step does not advance" check compares against vec[0] instead of current. A loop body that moves i backward to retry an iteration now throws, where before it simply repeated.
| line = line.substr(0, line.find_last_not_of(" \t") + 1);// remove tailing whitespaces | ||
| const size_t start = line.find_first_not_of(" \t\r"); | ||
| if (start == std::string::npos || line[start] == '#' || line[start] == '%') continue; | ||
| line = trim(stripConfigComment(accum + line), " \t\r"); |
There was a problem hiding this comment.
❓ question: Config lines no longer strip inline % comments, but the config version wasn't bumped. isCompatible() only checks the major version, so old configs silently parse differently. Do we want to bump the config version or do we consider this a bug with the old behaviour?
There was a problem hiding this comment.
🚩 issue: -sdf2udf will catch its own exception, log and exit status 0 on failure which contradicts the promise of a nonzero exit after action errors.
There was a problem hiding this comment.
🚩 issue: The PR switches stdin to binary mode (main.cpp:31-33), so on Windows a CRLF blank line in an OFF body arrives as "\r" instead of an empty line. That line gets parsed as data, which pushes a stale or uninitialized vertex or face.
| if (xyz[i].size == 4) { | ||
| float v = *(float*)(p + xyz[i].offset); | ||
| float v; | ||
| std::memcpy(&v, buffer.data() + xyz[i].offset, sizeof(v)); |
There was a problem hiding this comment.
🚩 issue: This is a pre-existing bug but might as well fix it if we are already changing this function. With a binary PLY, readPLY copies the raw bytes of int/int32 vertex properties into a float, so integer coordinates load as garbage values like 1.4e-45. The ASCII PLY path is correct.
| return grids[n.gridIdx].grid.get() == outputGridPtr.get() && | ||
| (n.dx || n.dy || n.dz); | ||
| }); | ||
| GridT::Ptr out_snap = needSnapshot ? grid->deepCopy() : nullptr; |
There was a problem hiding this comment.
🤓 nitpick (non-blocking): With keep=true, forValues deep-copies the grid twice, once for the output and once for the neighbor snapshot. That doubles peak memory. Neighbor reads could use the untouched original instead.
Signed-off-by: Ken Museth <ken.museth@gmail.com>
|
Thanks for the thorough review. All the comments were valid, and the latest push addresses each one: Half grids written back as 32-bit (writeVDB) Fatal errors missing from the -log file -for progress check compares against the start value instead of the current one Inline % comments in config files without a version bump -sdf2udf exits with status 0 on failure CRLF blank lines in OFF input on binary stdin Binary PLY with integer vertex coordinates Double deep copy in -forValues with keep=true All vdb_tool unit tests pass locally. |
swahtz
left a comment
There was a problem hiding this comment.
Looks good, thanks for addressing my notes.
Fixed some corner cases in vdb_tool, some uncovered by Astra in extreme mode, and others resulting from tests on the Thingi10K data set:
control-flow errors instead of entering invalid scopes.
the grid stack or names when voxel-kernel variable validation fails.
Inline comments now use '#'; '%' still supports full-line comments.
incomplete records.