GithubHelp home page GithubHelp logo

alecjacobson / computer-graphics-bounding-volume-hierarchy Goto Github PK

View Code? Open in Web Editor NEW
119.0 119.0 42.0 5.98 MB

Computer Graphics Assignment about Bounding Volume Hierarchies

CMake 3.66% C++ 60.89% C 11.96% CSS 23.48%

computer-graphics-bounding-volume-hierarchy's People

Contributors

abhimadan avatar alecjacobson avatar rarora7777 avatar texify[bot] avatar yig 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

computer-graphics-bounding-volume-hierarchy's Issues

CGAL missing

I get this when compiling cmake:

`-- CGAL not found.  Set the CGAL_DIR cmake variable or environment variable to the directory containing CGALConfig.cmake. This is either the binary directory where CGAL was configured or PREFIX/lib/CGAL for an installation.
CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
  libigl/shared/cmake/libigl.cmake:25 (find_package)
  CMakeLists.txt:27 (include)


CMake Warning at /usr/share/cmake-3.5/Modules/FindBoost.cmake:725 (message):
  Imported targets not available for Boost version
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindBoost.cmake:763 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.5/Modules/FindBoost.cmake:1332 (_Boost_MISSING_DEPENDENCIES)
  libigl/shared/cmake/libigl.cmake:25 (find_package)
  CMakeLists.txt:27 (include)


-- Could NOT find Boost
-- Could NOT find Matlab (missing:  Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY Matlab_MEX_EXTENSION Matlab_ROOT_DIR MEX_COMPILER MX_LIBRARY ENG_LIBRARY)
-- Could NOT find MOSEK (missing:  MOSEK_LIBRARIES MOSEK_INCLUDE_DIR)
-- Could NOT find OpenGL (missing:  OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR)
-- Creating target: igl::core (igl)
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
  Could NOT find OpenGL (missing: OPENGL_gl_LIBRARY OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.5/Modules/FindOpenGL.cmake:172 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  libigl/shared/cmake/libigl.cmake:316 (find_package)
  CMakeLists.txt:27 (include)`

I tried it on different machines too. Is this problem on my end?

ray_intersect_triangle_mesh_brute_force clarification

Does this mean V stores x, y, and z positions of every vertex?
// V #V by 3 list of mesh vertex positions
// F #F by 3 list of triangle indices into rows of V
Does this mean F stores indices of vertices in V, with 3 vertices in a row for each face?

How to insert

By reading the insert function and their .h files I am not pretty sure how it wants us to do it.

For example, in insert_box_into_box I understand ideally we should put some info about boundingbox A to boundingbox B so that if we later call boundingbox B we would somehow get data about boundingbox A. But by checking boundingbox.h I found bounding box only stores min_corner, max_corner nad center. How should we save more data in a boundingbox in order to insert another object in?

GLX: GLX version 1.3 is required ON CDF machines

When I try to run './rays' on a CDF machine, I see the text output but then I get this message:
'GLX: GLX version 1.3 is required'
Has anyone encountered this issue before and is aware of a solution?

Thanks

ray_box_intersect algorithm

I am following the book and slide's algo about ray_box_intersect in 3d, there is a corner case I am worrying. Normally if the ray intersect the box, the union of [txmin, txmax], [tymin, tymax] and [tzmin, tzmax] should not be empty, is this right?

What if we have a ray that is parallel to one of the axis so that the ray does intersect the box but only intersect with 2 of the 3 axes, shall we consider this corner case?

AABB left-right split

For determining the left-right split, do we get the midpoint along the longest axis and then compare if the centres of the objects are less than the midpoint then they're on the left and if the centre is greater than the midpoint then they're on the right? If this is the case, what should we do if this split results in no objects on the left and all the objects on the right? (One of the objects is very wide while 2 others are completely on one side)

Markus File Submission

It seems the required files on Markus is not consistent with the ones mentioned in readme.

AABBTree.cpp
box_box_intersect.cpp
find_all_intersecting_pairs_using_AABBTrees.cpp
insert_box_into_box.cpp
insert_triangle_into_box.cpp
nearest_neighbor_brute_force.cpp
point_AABBTree_squared_distance.cpp
point_box_squared_distance.cpp
point_triangle_squared_distance.cpp (we are not asked to implement this one since it is already given in MeshTriangle.h)
ray_intersect_box.cpp
ray_intersect_triangle.cpp
ray_intersect_triangle_mesh_brute_force.cpp
triangle_triangle_intersection.cpp

This is a list of files under current version of src dir.

Missing pthread.h and Vulcan when running cmake on Windows

When I run cmake, the follow two error lines come up:

Looking for pthread.h - not found
Could NOT find Vulkan (missing: VULKAN_LIBRARY VULKAN_INCLUDE_DIR)

Everything else seems to be fine.
Is there something I'm missing and should install?

Here is the full output when running cmake ..

-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.17763.
-- The C compiler identification is MSVC 19.22.27905.0
-- The CXX compiler identification is MSVC 19.22.27905.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.22.27905/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LIBIGL: D:/Solutions/MScAC Solutions/CSC2504 - Computer Graphics Solutions/computer-graphics-bounding-volume-hierarchy/libigl/include
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Creating target: igl::core (igl)
-- Creating target: igl::opengl (igl_opengl)
-- Found OpenGL: opengl32
-- Creating target: igl::opengl_glfw (igl_opengl_glfw)
-- Could NOT find Vulkan (missing: VULKAN_LIBRARY VULKAN_INCLUDE_DIR)
-- Using Win32 for window creation
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Solutions/MScAC Solutions/CSC2504 - Computer Graphics Solutions/computer-graphics-bounding-volume-hierarchy/build

How fast is fast enough?

Hello again.

I've set up the AABB tree structure but my build and quarry times are different than the example posted on the assignment page. My tree builds faster but querying takes longer. I'm using the DFS approach as was suggested to me in my previous post regarding the AABB tree.

Are the times that I'm getting fast enough or should I be trying to make a more balanced tree?

image

error on distances.cpp

When I tried to make the project, the terminal says
"error:
type 'igl::opengl::ViewerCore' does not provide a call operator
v.core().background_color.setConstant(0.8);"

Request for extention of assignment

Found that a lot of students got an unexpected amount of homework/exercise (411, 420 etc) this week so wonder if we can have an extension on this assignment for until weekend.

Can we assume that no two triangles are co-planar?

For triangle_triangle_intersection.cpp I was reading the lecture slide on "Triangle-Triangle Intersection". There, two algorithms are being proposed.

Algorithm 1 works for T1 & T2 when they are not co-planar and Algorithm 2 seems very complicated to implement.

Since I believe that we did not cover this topic during class, can we use algorithm 1 (thus assuming no two triangles are co planar) for the purpose of this lab? Or any suggestions/guidance?

make - fatal error igl/opengl/glfw/viewer.h: No such file or directory

I've been trying to compile the code in my home machine for some time now, but I couldn't find the appropriate package to install for "igl/opengl/glfw/viewer.h".

Attached below is the error message after make:

[ 41%] Built target glfw
[ 46%] Built target glad
[ 80%] Built target core
[ 82%] Building CXX object CMakeFiles/rays.dir/rays.cpp.o
In file included from /home/edwardyliu/Documents/projects/computer-graphics-bounding-volume-hierarchy/rays.cpp:9:0:
/home/edwardyliu/Documents/projects/computer-graphics-bounding-volume-hierarchy/include/visualize_aabbtree.h:6:36: fatal error: igl/opengl/glfw/viewer.h: No such file or directory
compilation terminated.
CMakeFiles/rays.dir/build.make:62: recipe for target 'CMakeFiles/rays.dir/rays.cpp.o' failed
make[2]: *** [CMakeFiles/rays.dir/rays.cpp.o] Error 1
CMakeFiles/Makefile2:107: recipe for target 'CMakeFiles/rays.dir/all' failed
make[1]: *** [CMakeFiles/rays.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Thank you!

Stack Overflow Error when running Rays on the Duck in Windows

When trying to build the tree on the duck, I run into the following stack overflow error:

image

The process memory on Visual Studio also spikes to 100MB.

The thing is, when I run this on the linux cdf machines, it works fine.

The torus works fine on both windows and linux.

Is Windows not allocating enough memory?
Is there anyway I can allow more memory?

How do we find the closest distance between a bounding box and a point?

to calculate point_box_squared_distance() we cannot simply just calculate from the center of the box to the query point right ?

Since this does not guarantee that all the points within that box is further away from query point (based on the center). This will then cause a problem when doing BFS traversal since it would just skip the bounding box, while actually still containing potential points closer to the query point than just the center coordinates value.

I was looking for any suggested method in the readme but couldn't find any. Am I approaching this question correctly?

Edit

Okay I think I figured it out.

Problem with make

When I was trying to make the executable, the following problem occurred, and I have no idea how to fix the problem. Can someone help me with this?

[ 82%] Building CXX object CMakeFiles/rays.dir/rays.cpp.o
[ 85%] Linking CXX executable rays
libcore.a(ray_intersect_triangle.cpp.o): In function `ray_intersect_triangle(Ray const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, double, double, double&)':
ray_intersect_triangle.cpp:(.text+0x113): undefined reference to `Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const'
ray_intersect_triangle.cpp:(.text+0x2d1): undefined reference to `Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const'
ray_intersect_triangle.cpp:(.text+0x2ee): undefined reference to `Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const'
ray_intersect_triangle.cpp:(.text+0x30b): undefined reference to `Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross_product_return_type<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::type Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::cross<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&) const'
collect2: error: ld returned 1 exit status
CMakeFiles/rays.dir/build.make:101: recipe for target 'rays' failed
make[2]: *** [rays] Error 1
CMakeFiles/Makefile2:107: recipe for target 'CMakeFiles/rays.dir/all' failed
make[1]: *** [CMakeFiles/rays.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Encountered CMake build error

Already pulled the latest assignment version from github. But still can not make a release/debug build. Getting the following message:
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found LIBIGL: /home/fengchen/Desktop/CSC418_A4/libigl/include
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Creating target: igl::core (igl)
-- Creating target: igl::opengl (igl_opengl)
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY
OPENGL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.10/Modules/FindOpenGL.cmake:369 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
libigl/cmake/libigl.cmake:321 (find_package)
cmake/FindLIBIGL.cmake:36 (include)
CMakeLists.txt:10 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/fengchen/Desktop/CSC418_A4/build/CMakeFiles/CMakeOutput.log".
See also "/home/fengchen/Desktop/CSC418_A4/build/CMakeFiles/CMakeError.log".

Clarification for "careful: if the ray or min_t lands inside the box this could still hit something stored inside the box, so this counts as a hit "

What does this warning mean ? " careful: if the ray or min_t lands inside the box this could still hit something stored inside the box, so this counts as a hit ".

Also, from my understanding of the variable t, it should hold the parametric distance of the ray to the first hit of the box on the edges. So what does the sentence "min_t lands inside the box" really mean?

Project Build Issue

Hi,

When I try to build the project in release mode, it reports the following error:
ld: warning: text-based stub file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList.tbd and library file /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList are out of sync. Falling back to library file for linking.
Undefined symbols for architecture x86_64:
"nearest_neighbor_brute_force(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, int&, double&)", referenced from:
_main in distances.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [distances] Error 1
make[1]: *** [CMakeFiles/distances.dir/all] Error 2
make: *** [all] Error 2

It seems we are missing some header definition in distances.cpp. Thanks in advance!

Issues during CMAKE on WSL

I am able to run CMAKE in release mode on WSL but I received the following msg:

-- Could NOT find Vulkan (missing: VULKAN_LIBRARY VULKAN_INCLUDE_DIR)

Does it matter to not have the Vulkan library? or do I need to install Vulkan library for this assignment?

Same intersecting pairs "not found"?

Hello,

While running the intersecting-pairs algorithm, I noticed something odd. I'm getting the error about how certain pairs are found in brute force that aren't found in tree traversal, and vice-versa. But the odd thing is, the pair not found actually is being found, but the ordering of the triangle ids is different. See here:
pair not in tree
and:
pair not in brute force
These are both from a single run of intersections.exe. This is also just one example, there are many other "unfound pairs" just like this in the same lists, such as (47, 6) and (6, 47), or (8, 16) and (16, 8).
Does this mean that there is something wrong with my implementation, or is this a potential oversight? Because said intersections are the exact same intersections, just with the triangle-ids swapped.

Can we include <Eigen/Geometry> library?

When I calculate the t for ray_intersect_triangle, I used a method that requires cross product between two vectors instead of the method on the book that uses determinant and Cramer’s rule. I notice <Eigen/Geometry> is required for the cross product between two vectors. Can I use it?

Issues on X11 and GLFW for WSL

I received the following errors:

X11: The DISPLAY environment variable is missing
The GLFW library is not initialized
The GLFW library is not initialized
The GLFW library is not initialized
Segmentation fault (core dumped)

And I tried to set
export DISPLAY=localhost:0.0

and then I got

X11: Failed to open display localhost:0.0
The GLFW library is not initialized
The GLFW library is not initialized
The GLFW library is not initialized
Segmentation fault (core dumped)

What should I do now?

Unresolved external symbol with Eigen::Matrix3d::determinant() and Eigen::Vector3d::cross(v)

Platform: Windows 10 with Visual Studio 2019
I have recursively clone all the components

For ray_intersection_triangle.cpp, I directly copy-paste the code I have during HW2(which works at that time), but can't go through the building session in current solutions. The Error Code is LNK 2019 which means the determinant() function is not supported there.
A similar error happened with Vector3d.Cross() and Vector3D.Dot(), which is crucial but I have no idea why.
I've detailly checked the data and turned out to be that all the data are legal and being correctly instantiated before use. It is kinda weird for those things to happen.

Below are the error message prints
InkedEigen_determinant_LI

Eigen_cross

core.lib error in Visual Studio

I finish building the program using CMake for Visual Studio. But when I tried to run the program through Visual Studio, it run into an error regards core.lib:
1-1

How to check if a subtree is a leaf?

Under section "Distance queries":

  1. In the BFS pseudocode, it specifically asks us to check "if subtree is a leaf" after checking if d_s<d.
    I was thinking of checking the object type by de-referencing the object smart pointer, but that does not seem feasible.
    Are there other ways to do this? If yes, how?

  2. When inserting a distance-subtree pair into the priority queue: Q.insert(d_l, subtree.left)
    If we initialize the priority queue to handle (double, shared_ptr<AABBTree>), but if subtree.left is type (shared_ptr<Object >) - how do we resolve this?

What partitioning strategy should we use for AABB tree?

The assignment only mentions to split along the midpoint of the longest axis of the box, but doesn't mention how to deal with objects that fall in both halves. Are we supposed to come up with our own partitioning method in these situations, or is there one we are supposed to follow?

If we are making our own, somebody else mentioned an issue where all objects fall on the same side if there is a big object that determines the size of the longest axis of the box. In this case should we just pick any object that falls on one side of the tree and place it in the other to create overlapping sub trees, or is there a more optimal way?

Thanks,

Uneven Split generated from creating an AABBTree

my ./rays output didn't look exactly like the one provided but I thought it was because of the random splitting of objects when all objects end up on one side of the splitting point
But now while debugging, I found that this uneven split happens for as many as 40 objects i.e. all 40 objects are classified to be on one side of the splitting point
I remember the professor said that this uneven splitting should occur near the leafs but it looks like mine occurs much higher in the tree
Did anyone experience something similar?

Thanks

smart pointer

when I am doing the second part of the assignment. I notice that if I use

const std::shared_ptr node = q.top().second; (create a copy of the smart pointer). Everything will correct and the brute force and tree search match.

But if I switch to const std::shared_ptr& node = q.top().second; (create a reference to the smart pointer)

The result no longer matches.

Is it some special property of smarter pointer?

AABBTree_ray_intersect.cpp how to quarry

Are we supposed to use the textbook implementation to quarry in this case? The BFS approach described in the assignment requires us to be getting the distance to the bounding box at each subtree, but our bounding box intersection function isn't supposed to return distance information so I'm not sure if we are supposed to use this...

Error: YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES, Release\core.lib cannot be opened

Hello,
I am having an issue where when I build the project, I receive the errors listed in the title.

For the first error - YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES - the description points me to ray_intersect_triangle_mesh_brute_force, with file being set as cwisebinaryop.h. However, even when I commented out everything except the return statement in the brute force algorithm, the error still exists. When using Debug->Start New Instance for Ray, I get the same error, but it no longer says that the error is occurring in the ray_intersect_triangle_mesh_brute_force file (In fact, it doesn't even specify where in what file the program is being raised, except for "cwisebinaryop.h". These are the resulting error lists:

build

start new instance

Alongside this, I am also getting the error "cannot open input file Release\core.lib" when I build the project and when performing the Start New Instance thing (I assume this has to do with the previous error?). Does anyone know why this is happening, and what I can do to fix this?

Edit: Nevermind, I miss-read the error, and I believe I found the problem.

I might have found a bug in your code ... ?

in the file intersections.cpp, the functions triangle_tree(VA,FA) and triangle_tree(VB,FB) seems to change FA and FB implicitly.

if you change the file intersections.cpp from

73 std::shared_ptr rootA = triangle_tree(VA,FA);
74 std::shared_ptr rootB = triangle_tree(VB,FB);

to

73 std::cout << "the following six rows are fine." << std::endl;
std::cout << VA.row(FA(8218,0)) << std::endl;
std::cout << VA.row(FA(8218,1)) << std::endl;
std::cout << VA.row(FA(8218,2)) << std::endl;
std::cout << VB.row(FB(1305,0)) << std::endl;
std::cout << VB.row(FB(1305,1)) << std::endl;
std::cout << VB.row(FB(1305,2)) << std::endl;
std::shared_ptr rootA = triangle_tree(VA,FA);
std::shared_ptr rootB = triangle_tree(VB,FB);
std::cout << "now black magic starts." << std::endl;
std::cout << VA.row(FA(8218,0)) << std::endl;
84 std::cout << VA.row(FA(8218,1)) << std::endl;
std::cout << VA.row(FA(8218,2)) << std::endl;
std::cout << VB.row(FB(1305,0)) << std::endl;
std::cout << VB.row(FB(1305,1)) << std::endl;
88 std::cout << VB.row(FB(1305,2)) << std::endl;

you will probably find a segmentation fault when executing
./intersections ../data/knight.obj ../data/cheburashka.obj till line 84.

Please correct me if I'm wrong! Thanks a lot for your time!
intersections.cpp.txt

data structure

whats structure of V and F in "ray_intersect_triangle_mesh_brute_force.cpp", dont quite understand
// V #V by 3 list of mesh vertex positions
// F #F by 3 list of triangle indices into rows of V

Algorithm for triangle triangle intersection

About triangle triangle intersection, I didnt see any algorithm on the book. After searching online I did find some paper talking about it like this one: http://fileadmin.cs.lth.se/cs/personal/tomas_akenine-moller/code/tritri_tam.pdf
, but it seems to be very time-consuming for me to implement it in C++. I am wondering are we suppose to do research and implementation about triangle triangle intersection by ourselves? Or is there any easy reference somewhere that I missed?

AABB Tree Infinite Recursion

Hi,
I encountered a problem that AABB tree includes all objects into its left node and the bounding box never shrinks (Since there is a large object on the midpoint along the longest axis). How should we handle this case? Here is some output (print msg). Maybe I misunderstand the initialization algorithm?

objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000
objects size is: 255
Box center is: -0.56930700000 -0.78500950000 -0.56930700000, diagonal is: 4.75805800000 4.35410100000 4.75805800000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78500950000 -0.78354500000
Diagonal is: 4.75805800000 4.35410100000 4.32512000000
Detect object.box.center(maxIndex) == center(maxIndex)
object.box.center is: -0.56930700000 -0.78354500000 -0.57263450000
Diagonal is: 4.75805800000 4.32512000000 4.72787100000

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.