mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 11:52:50 +08:00
small numerical fix to point_mesh
Summary: Small fix by adjusting the area `eps` to account for really small faces when computing point to face distances Reviewed By: bottler Differential Revision: D34331336 fbshipit-source-id: 51c4888ea46fefa4e31d5b0bb494a9f9d77813cd
This commit is contained in:
parent
3de41223dd
commit
ee71c7c447
@ -550,7 +550,7 @@ __device__ inline bool IsInsideTriangle(
|
|||||||
const float3& v1,
|
const float3& v1,
|
||||||
const float3& v2) {
|
const float3& v2) {
|
||||||
bool inside;
|
bool inside;
|
||||||
if (AreaOfTriangle(v0, v1, v2) < 1e-5) {
|
if (AreaOfTriangle(v0, v1, v2) < 5e-3) {
|
||||||
inside = 0;
|
inside = 0;
|
||||||
} else {
|
} else {
|
||||||
float3 bary = BarycentricCoords3Forward(p, v0, v1, v2);
|
float3 bary = BarycentricCoords3Forward(p, v0, v1, v2);
|
||||||
|
@ -651,7 +651,7 @@ static bool IsInsideTriangle(
|
|||||||
const vec3<T>& v1,
|
const vec3<T>& v1,
|
||||||
const vec3<T>& v2) {
|
const vec3<T>& v2) {
|
||||||
bool inside;
|
bool inside;
|
||||||
if (AreaOfTriangle(v0, v1, v2) < 1e-5) {
|
if (AreaOfTriangle(v0, v1, v2) < 5e-3) {
|
||||||
inside = 0;
|
inside = 0;
|
||||||
} else {
|
} else {
|
||||||
vec3<T> bary = BarycentricCoords3Forward(p, v0, v1, v2);
|
vec3<T> bary = BarycentricCoords3Forward(p, v0, v1, v2);
|
||||||
|
@ -11,7 +11,11 @@ import torch
|
|||||||
from common_testing import TestCaseMixin, get_random_cuda_device
|
from common_testing import TestCaseMixin, get_random_cuda_device
|
||||||
from pytorch3d import _C
|
from pytorch3d import _C
|
||||||
from pytorch3d.loss import point_mesh_edge_distance, point_mesh_face_distance
|
from pytorch3d.loss import point_mesh_edge_distance, point_mesh_face_distance
|
||||||
from pytorch3d.structures import Meshes, Pointclouds, packed_to_list
|
from pytorch3d.structures import (
|
||||||
|
Meshes,
|
||||||
|
Pointclouds,
|
||||||
|
packed_to_list,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||||
@ -126,7 +130,7 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
|||||||
area = torch.cross(v0, v1).norm() / 2.0
|
area = torch.cross(v0, v1).norm() / 2.0
|
||||||
|
|
||||||
# check if triangle is a line or a point. In that case, return False
|
# check if triangle is a line or a point. In that case, return False
|
||||||
if area < 1e-5:
|
if area < 5e-3:
|
||||||
return False
|
return False
|
||||||
bary = TestPointMeshDistance._point_to_bary(point, tri)
|
bary = TestPointMeshDistance._point_to_bary(point, tri)
|
||||||
inside = ((bary >= 0.0) * (bary <= 1.0)).all()
|
inside = ((bary >= 0.0) * (bary <= 1.0)).all()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user