0
\$\begingroup\$

I'm in the process of parsing a BSP file to create btConvexHullShape objects for each brush. I've seen a few examples of how to do this on Github and they all use the getVerticesFromPlaneEquations function. This function in turn uses isPointInsidePlanes. The problem I'm having is that isPointInsidePlanes returns false for every potentialVertex, leaving me with an empty verticesOut array.

I'm looking at the code for isPointInsidePlanes, and it seems like it is checking the vertex against ALL planes in the brush which I find confusing.

For example if the brush is a simple rectangular prism, you wouldn't expect the point that results from the intersection of 3 planes to be inside all 6 planes, right? Shouldn't it only be checked against the 3 planes that intersected to locate it?

Now this file hasn't changed in 9 years, so either I'm doing something very wrong or nobody uses this function. I'm going to assume I'm wrong for the time being.

TL;DR: Why does isPointInsidePlanes check the point against every plane equation and not just the 3 that intersect to create it? Should I not even be using the getVerticesFromPlaneEquations function and instead be using something else?

EDIT: Added link to code

Here is a link to the relevant source file: https://github.com/bulletphysics/bullet3/blob/master/src/LinearMath/btGeometryUtil.cpp

Specifically, on line 175, the planeEquations array is passed to isPointInsidePlanes which then compares the point against every plane in the array.

\$\endgroup\$
0
\$\begingroup\$

It turns out I had a fundamental misunderstanding of the purpose of the "isPointInsidePlanes" function. It is not checking whether the point lies on every plane. It is checking whether the point is behind every plane (since the normals of the planes point outwards) which ensures that the shape is convex.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.