mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
Improved contains_hexahedron function little bit
This commit is contained in:
parent
ae8c460b1b
commit
900fe8b650
@ -419,20 +419,23 @@ contains_hexahedron(const BoundingHexahedron *hexahedron) const {
|
|||||||
// completely outside of the hexahedron.
|
// completely outside of the hexahedron.
|
||||||
return IF_no_intersection;
|
return IF_no_intersection;
|
||||||
|
|
||||||
} else if (dist < 0.0f && dist2 < radius2) {
|
} else {/*if (dist < 0.0f && dist2 < radius2) {*/
|
||||||
// The sphere is not completely behind this plane, but some of
|
// The sphere is not completely behind this plane, but some of
|
||||||
// it is.
|
// it is.
|
||||||
|
|
||||||
// Look a little closer.
|
// Look a little closer.
|
||||||
bool all_in = true;
|
unsigned points_out = 0;
|
||||||
for (int i = 0; i < 8 && all_in; ++i) {
|
for (int i = 0; i < 8; ++i) {
|
||||||
if (p.dist_to_plane(hexahedron->get_point(i)) < 0.0f) {
|
if (p.dist_to_plane(hexahedron->get_point(i)) > 0.0f) {
|
||||||
// This point is outside the plane.
|
// This point is outside the plane.
|
||||||
all_in = false;
|
++points_out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!all_in) {
|
if (points_out != 0) {
|
||||||
|
if (points_out == 8) {
|
||||||
|
return IF_no_intersection;
|
||||||
|
}
|
||||||
result &= ~IF_all;
|
result &= ~IF_all;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,8 +467,6 @@ set_planes() {
|
|||||||
_planes[4] = Planef(_points[3], _points[4], _points[0]);
|
_planes[4] = Planef(_points[3], _points[4], _points[0]);
|
||||||
_planes[5] = Planef(_points[4], _points[7], _points[6]);
|
_planes[5] = Planef(_points[4], _points[7], _points[6]);
|
||||||
|
|
||||||
nassertv(_planes[0].dist_to_plane(_centroid) < 0);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// No, a perfectly sane universe.
|
// No, a perfectly sane universe.
|
||||||
_planes[1] = Planef(_points[0], _points[1], _points[5]);
|
_planes[1] = Planef(_points[0], _points[1], _points[5]);
|
||||||
@ -474,6 +475,13 @@ set_planes() {
|
|||||||
_planes[4] = Planef(_points[3], _points[0], _points[4]);
|
_planes[4] = Planef(_points[3], _points[0], _points[4]);
|
||||||
_planes[5] = Planef(_points[4], _points[6], _points[7]);
|
_planes[5] = Planef(_points[4], _points[6], _points[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nassertv(_planes[0].dist_to_plane(_centroid) <= 0.001);
|
||||||
|
nassertv(_planes[1].dist_to_plane(_centroid) <= 0.001);
|
||||||
|
nassertv(_planes[2].dist_to_plane(_centroid) <= 0.001);
|
||||||
|
nassertv(_planes[3].dist_to_plane(_centroid) <= 0.001);
|
||||||
|
nassertv(_planes[4].dist_to_plane(_centroid) <= 0.001);
|
||||||
|
nassertv(_planes[5].dist_to_plane(_centroid) <= 0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user