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;

bvh3's People

Contributors

valbok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

alexsaen

bvh3's Issues

Stackoverflow error due to infinite recursion

Hey, I was trying to use your library for some work. I noticed that for simple cloth geometry, the buidtree function does not return from recursion and ultimately gives a stack overflow. My code is this may be I am doing anything wrong but you can take a look.

typedef NBvh3::KDop<16> TKDop16;
typedef NBvh3::Node<TKDop16> TNodeKDop16;
TNodeKDop16* pRoot;
NBvh3::TVertices triangles;
for (i = 0; i < indices.size(); i += 3) {
   glm::vec3 p1 = X[indices[i]];
   glm::vec3 p2 = X[indices[i + 1]];
   glm::vec3 p3 = X[indices[i + 2]];
		
   NBvh3::SVertex v1(p1.x, p1.y, p1.z);
   NBvh3::SVertex v2(p2.x, p2.y, p2.z);
   NBvh3::SVertex v3(p3.x, p3.y, p3.z);

   triangles.push_back(v1);
   triangles.push_back(v2);
   triangles.push_back(v3);
}
pRoot = NBvh3::buildTree<TKDop16>(triangles);

And this is the error that I get on my win10 x64 machine with MS Visual Studio 2019 community edition.
image
Any ideas on what could be causing this and how to fix this?

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.