GithubHelp home page GithubHelp logo

gerazo / loose_quadtree Goto Github PK

View Code? Open in Web Editor NEW
63.0 3.0 7.0 27 KB

Loose Quadtree (Region Tree) simple C++11 implementation

License: MIT License

CMake 1.10% Shell 2.66% C++ 96.24%
quadtree

loose_quadtree's People

Contributors

gerazo avatar hemofektik avatar wohlstand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

loose_quadtree's Issues

assertion failure in Impl::InsertIntoTree

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}

Misuse of std::vector<T>::reserve

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.