MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / loadPrimitivesFromFile

Method loadPrimitivesFromFile

Source/Falcor/Scene/SDFs/SDFGrid.cpp:380–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378 }
379
380 uint32_t SDFGrid::loadPrimitivesFromFile(const std::filesystem::path& path, uint32_t gridWidth)
381 {
382 std::ifstream ifs(path);
383 if (!ifs.good())
384 {
385 logWarning("Failed to open SDF grid file '{}' for reading.", path);
386 return false;
387 }
388
389 std::vector<SDF3DPrimitive> primitives;
390 try
391 {
392 json j = json::parse(ifs);
393 primitives = j;
394 }
395 catch (const std::exception& e)
396 {
397 logWarning("Error when deserializing SDF grid from '{}': {}", path, e.what());
398 return 0;
399 }
400
401 setPrimitives(primitives, gridWidth);
402
403 mInitializedWithPrimitives = true;
404 return (uint32_t)mPrimitives.size();
405 }
406
407 bool SDFGrid::writePrimitivesToFile(const std::filesystem::path& path)
408 {

Callers 1

FALCOR_SCRIPT_BINDINGFunction · 0.80

Calls 4

whatMethod · 0.80
logWarningFunction · 0.50
parseFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected