GithubHelp home page GithubHelp logo

Comments (2)

feragon avatar feragon commented on August 24, 2024

That's right, this test fails:

TEST(Test, Test) {
    lc::QuadTree<lc::entity::CADEntity_CSPtr> qt;
    qt.insert(std::make_shared<lc::entity::Line>(lc::geo::Coordinate(-5000, -5000),
                                                 lc::geo::Coordinate(5000, 5000),
                                                 std::make_shared<lc::Layer>())
    );

    ASSERT_EQ(0, qt.retrieve(lc::geo::Area(lc::geo::Coordinate(1, -1), lc::geo::Coordinate(5000, -5000))).size()); //Returns 1 element
}

from librecad_3.

rvt avatar rvt commented on August 24, 2024

In context of quad tree this is correct. The quad tree doesn't care about exact coordinates but it just finds the area's that include (even partially) in the requested area.
Since the bounding box of the lines falls over the boundig box of the requested area the line is included.

For painting it matters such that element's really outside of a quad will not be retreived, but even taht depends.

For example if you have 10 elements in a quad tree, no matter what you do, you will always retrieve them all. If you have 1000 they will be pushed down the quad tree levels and store them at finer granularity.

This could even optmise painting during canvas moving. Because you could easely request all entities up to some level X and you will only get a maximum number of entities but nothing below that (if it applies).

For the painter is doesn't matter much in some conditions. We need to be carefull not to optimise to much because sometimes it can be faster to just paint it rather than to find out if we need to paint it. The quad tree just helps with it... We do have some more exact routines that can find all entities within a bounding box, thet just take a lot more time to calculate.

For OpenGL it could even slow things down because with OpenGL you can keep everything in memory (I hope :) ) and as such it's properly faster to let the GPU handle it.
In addition, both the painter and kernel can use there own implementation to speed up operations if they wish...

Hope that makes sense...

from librecad_3.

Related Issues (20)

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.