Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
1. special format of obj file(with only 1 F term)
2. Grid sample under too small area
  • Loading branch information
ZhouYixuanRobtic committed Dec 10, 2024
1 parent 000a4d7 commit 6740f44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/API/MSGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void MSGrid::generateSamplesInternal(Array<Surface::Point> *pts, int numSamples,
// get normal
Vector3D n;
sur.getTriangleNormal(&n, i);

if (num > 1) {
float tArea = areaTriangle(p[0], p[1], p[2]);
if (num > 1 && tArea >= 1e-6) {
// generate random samples on the triangle
Array<Point3D> points;
sampleTriangleGrid(&points, num, p);
Expand All @@ -98,7 +98,7 @@ void MSGrid::generateSamplesInternal(Array<Surface::Point> *pts, int numSamples,
p->p = points.index(j);
p->n = n;
}
} else /*if (num == 1)*/ {
} else /*if (num == 1 || tArea < 1e-6)*/ {
// should we use incenter ??
Surface::Point *s = &pts->addItem();
s->n = n;
Expand Down
6 changes: 4 additions & 2 deletions src/Surface/OBJLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ bool loadOBJ(Surface *sur, const char *fileName, float boxSize) {

// decode token
int a = 0, b = 0, c = 0;
if (token == NULL || (sscanf(token, "%d/%d/%d", &a, &b, &c) != 3 &&
sscanf(token, "%d//%d", &a, &c) != 2)) {
if (token == NULL ||
(sscanf(token, "%d/%d/%d", &a, &b, &c) != 3 &&
sscanf(token, "%d//%d", &a, &c) != 2 &&
sscanf(token, "%d", &a) != 1)){
fclose(f);
return false;
}
Expand Down

0 comments on commit 6740f44

Please sign in to comment.