diff options
author | Marius Kintel <marius@kintel.net> | 2012-01-29 18:01:15 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-01-29 18:01:15 (GMT) |
commit | 3c3bb91520ea841ef20b9bf7e6dd162abd1cfaa1 (patch) | |
tree | 5d9e7f0368ccf860e50e08f7d98d5715f85a1042 /tests/csgtestcore.cc | |
parent | 65181c9ad63f2631c0add7fc1a68bf7b3388ac58 (diff) |
Bugfix for tests: Empty tree after normalization
Diffstat (limited to 'tests/csgtestcore.cc')
-rw-r--r-- | tests/csgtestcore.cc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index 06b9d7b..e89f4a6 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -301,13 +301,16 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) // CSG normalization CSGTermNormalizer normalizer; csgInfo.root_norm_term = normalizer.normalize(root_raw_term, 5000); - - assert(csgInfo.root_norm_term); + if (csgInfo.root_norm_term) { + csgInfo.root_chain = new CSGChain(); + csgInfo.root_chain->import(csgInfo.root_norm_term); + fprintf(stderr, "Normalized CSG tree has %d elements\n", int(csgInfo.root_chain->polysets.size())); + } + else { + csgInfo.root_chain = NULL; + fprintf(stderr, "WARNING: CSG normalization resulted in an empty tree\n"); + } - csgInfo.root_chain = new CSGChain(); - csgInfo.root_chain->import(csgInfo.root_norm_term); - fprintf(stderr, "Normalized CSG tree has %d elements\n", int(csgInfo.root_chain->polysets.size())); - if (csgInfo.highlight_terms.size() > 0) { cerr << "Compiling highlights (" << csgInfo.highlight_terms.size() << " CSG Trees)...\n"; @@ -339,12 +342,14 @@ int csgtestcore(int argc, char *argv[], test_type_e test_type) enable_opencsg_shaders(csgInfo.glview); if (sysinfo_dump) cout << info_dump(csgInfo.glview); - BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); - - Vector3d center = (bbox.min() + bbox.max()) / 2; - double radius = (bbox.max() - bbox.min()).norm() / 2; - + Vector3d center(0,0,0); + double radius = 1.0; + if (csgInfo.root_chain) { + BoundingBox bbox = csgInfo.root_chain->getBoundingBox(); + center = (bbox.min() + bbox.max()) / 2; + radius = (bbox.max() - bbox.min()).norm() / 2; + } Vector3d cameradir(1, 1, -0.5); Vector3d camerapos = center - radius*1.8*cameradir; csgInfo.glview->setCamera(camerapos, center); |