gerazo / loose_quadtree Goto Github PK
View Code? Open in Web Editor NEWLoose Quadtree (Region Tree) simple C++11 implementation
License: MIT License
Loose Quadtree (Region Tree) simple C++11 implementation
License: MIT License
Having integrated your loose quadtree implementation into my game project early in development, I'm getting an off-by-one assertion failure during insertion.
This crash happens deterministically so I can provide additional details if you need them.
assertion failed: effective_bounds.Contains(object_bounds) in F:/dev/game/./compat/LooseQuadtree-impl.h:1114
(gdb) bt 5
#0 0x00007ff64c2fc032 in floormat::_fm_abort () at F:/dev/game/./compat/assert.hpp:32
#1 0x00007ff64c30b846 in loose_quadtree::LooseQuadtree<short, loose_quadtree::BoundingBox<short>, loose_quadtree::TrivialBBExtractor<short> >::Impl::InsertIntoTree (this=0x2a975dcf810, object=0x2a975e11380)
at F:/dev/game/./compat/LooseQuadtree-impl.h:1114
#2 0x00007ff64c30a5d9 in loose_quadtree::LooseQuadtree<short, loose_quadtree::BoundingBox<short>, loose_quadtree::TrivialBBExtractor<short> >::Impl::Insert (this=0x2a975dcf810, object=0x2a975e11380)
at F:/dev/game/./compat/LooseQuadtree-impl.h:824
#3 0x00007ff64c48f8af in loose_quadtree::LooseQuadtree<short, loose_quadtree::BoundingBox<short>, loose_quadtree::TrivialBBExtractor<short> >::Insert (this=0x2a975dcf810, object=0x2a975e11380)
at F:/dev/game/./compat/LooseQuadtree-impl.h:1162
#4 0x00007ff64c48e007 in floormat::chunk::ensure_passability (this=0x2a975dd1fe8)
at F:/dev/game/src/chunk-bbox.cpp:109
(More stack frames follow...)
(gdb) fr 1
#1 0x00007ff64c30b846 in loose_quadtree::LooseQuadtree<short, loose_quadtree::BoundingBox<short>, loose_quadtree::TrivialBBExtractor<short> >::Impl::InsertIntoTree (this=0x2a975dcf810, object=0x2a975e11380)
at F:/dev/game/./compat/LooseQuadtree-impl.h:1114
1114 assert(effective_bounds.Contains(object_bounds));
(gdb) l
1109 (Number)((typename detail::MakeDistance<Number>::Type)effective_bounds.height / 2);
1110 effective_bounds.width = (Number)(effective_bounds.width * 2);
1111 effective_bounds.height = (Number)(effective_bounds.height * 2);
1112 effective_bounds.left = (Number)(effective_bounds.left - half_width);
1113 effective_bounds.top = (Number)(effective_bounds.top - half_height);
1114 assert(effective_bounds.Contains(object_bounds));
1115 #endif
1116
1117 typename detail::TreeNode<Object>::ObjectContainer& objects =
1118 trav.GetNode()->objects;
(gdb) p effective_bounds
$1 = {left = 671, top = 353, width = 128, height = 126}
(gdb) p object_bounds
$2 = {left = 672, top = 352, width = 64, height = 64}
Running the LooseQuadtreeTest.cpp in MSVC causes an exception because on stl vector is called reserve() instead of resize():
std::vector<BoundingBox<NumberT>> objects;
objects.reserve(objects_generated);
The following code is accessing the objects via the operator[] but this may cause undefined behavior based on the STL implementation, since the size() of a vector does not change by calling reserve on it.
When fixing it, the compiler complains about BoundingBox not having a default constructor. Either the testing code needs to be changed to work somehow else or a default constructor needs to be added to the BoundingBox class.
Regards,
Richard
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.