Giter Club home page Giter Club logo

bvh3's Introduction

Bounding Volume Hierarchy Tree

Введение в дискретно-ориентированные многогранники для задачи определения столкновений.

Simple implementation of BVH-tree using k-DOP as a bounding volume for Collision Detection task. Bhv3 is a binary tree that allows to search collided object elements effectively.

k-DOP

Discrete Orientation Polytopes - the bounding volume that provides an ability to reduce cost of collision detection. Is a convex polytope bounded by k hyperplanes with fixed orientations.

Only 16, 18 and 24 planes have been implemented there.

Build

$ cmake .; make

Run a test:

$ ./bvh3/tests/NodeTest

Example

Two different dots should not collide (16 - is a number of planes):

KDop<16> bv1({3, 1, 0});
KDop<16> bv2({1, 5, 0});
EXPECT_FALSE(bv1.overlapped(bv2));

Creating one k-DOP from two:

KDop<16> bv1({3, 1, 0});
KDop<16> bv2({1, 5, 0});
bv1 += bv2;

Creating a tree:

TVertices vertex1 =
{
    {3, 1, 0}
};

TVertices vertex2 =
{
    {3, 3, 0}
};

auto root1 = buildTree<KDop<16> >(vertex1);
auto root2 = buildTree<KDop<16> >(vertex2);
TNodeKDop16::TCollidedNodes output;
// No collision found
bool found = root1->collided(root2, output);
EXPECT_FALSE(found);
delete root1;
delete root2;

Unfortunatelly line collided with just a dot:

TVertices vertices1 =
{
    {3, 1, 0},
    {1, 5, 0}
};

TVertices vertices2 =
{
    {3, 3, 0}
};

auto root1 = buildTree<KDop<16> >(vertices1);
auto root2 = buildTree<KDop<16> >(vertices2);

TNodeKDop16::TCollidedNodes output;
bool found = root1->collided(root2, output);
EXPECT_TRUE(found);

delete root1;
delete root2;

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.