Check mesh extend before going through triangles

This commit is contained in:
Atlante45 2015-04-23 16:40:40 +02:00
parent 99fd590a90
commit bda72025af
2 changed files with 5 additions and 1 deletions

View file

@ -1060,7 +1060,7 @@ float EntityItem::getRadius() const {
return 0.5f * glm::length(_dimensions);
}
bool EntityItem::contains(const glm::vec3 &point) const {
bool EntityItem::contains(const glm::vec3& point) const {
switch (getShapeType()) {
case SHAPE_TYPE_BOX: {
// Transform point to be in a space where the box is a 1m cube centered on the origin.

View file

@ -127,6 +127,10 @@ Extents FBXGeometry::getUnscaledMeshExtents() const {
// TODO: Move to model::Mesh when Sam's ready
bool FBXGeometry::convexHullContains(const glm::vec3& point) const {
if (!getUnscaledMeshExtents().containsPoint(point)) {
return false;
}
auto checkEachPrimitive = [=](FBXMesh& mesh, QVector<int> indices, int primitiveSize) -> bool {
// Check whether the point is "behind" all the primitives.
for (unsigned int j = 0; j < indices.size(); j += primitiveSize) {