Fix inbetween mesh normal.
parent
c4287c5484
commit
167a97e66a
17
src/bmesh.c
17
src/bmesh.c
|
@ -821,11 +821,22 @@ void calculateBallQuad(bmeshBall *ball, quad *q) {
|
||||||
vec3Add(&q->pt[3], &z, &q->pt[3]);
|
vec3Add(&q->pt[3], &z, &q->pt[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawWallsBetweenQuads(quad *q1, quad *q2) {
|
static void drawWallsBetweenQuads(vec3 *origin, quad *q1, quad *q2) {
|
||||||
int i;
|
int i;
|
||||||
|
vec3 normal;
|
||||||
|
vec3 o2v;
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
quad wall = {{q1->pt[i], q2->pt[i],
|
quad wall = {{q1->pt[i], q2->pt[i],
|
||||||
q2->pt[(i + 1) % 4], q1->pt[(i + 1) % 4]}};
|
q2->pt[(i + 1) % 4], q1->pt[(i + 1) % 4]}};
|
||||||
|
vec3Normal(&wall.pt[0], &wall.pt[1], &wall.pt[2], &normal);
|
||||||
|
vec3Sub(&wall.pt[0], origin, &o2v);
|
||||||
|
if (vec3DotProduct(&o2v, &normal) < 0) {
|
||||||
|
int j;
|
||||||
|
quad oldWall = wall;
|
||||||
|
for (j = 0; j < 4; ++j) {
|
||||||
|
wall.pt[j] = oldWall.pt[3 - j];
|
||||||
|
}
|
||||||
|
}
|
||||||
drawQuad(&wall);
|
drawQuad(&wall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -845,7 +856,7 @@ static int bmeshGenerateInbetweenMeshFrom(bmesh *bm, bmeshBall *parent,
|
||||||
if (parent && parent->radius > 0) {
|
if (parent && parent->radius > 0) {
|
||||||
quad parentFace;
|
quad parentFace;
|
||||||
calculateBallQuad(parent, &parentFace);
|
calculateBallQuad(parent, &parentFace);
|
||||||
drawWallsBetweenQuads(&parentFace, ¤tFace);
|
drawWallsBetweenQuads(&ball->position, &parentFace, ¤tFace);
|
||||||
child = bmeshGetBallFirstChild(bm, ball, &iterator);
|
child = bmeshGetBallFirstChild(bm, ball, &iterator);
|
||||||
if (!child) {
|
if (!child) {
|
||||||
bmeshBall fakeParentParent = *parent;
|
bmeshBall fakeParentParent = *parent;
|
||||||
|
@ -857,7 +868,7 @@ static int bmeshGenerateInbetweenMeshFrom(bmesh *bm, bmeshBall *parent,
|
||||||
vec3Lerp(&fakeParentParent.position, &fakeParent.position, 2,
|
vec3Lerp(&fakeParentParent.position, &fakeParent.position, 2,
|
||||||
&fakeBall.position);
|
&fakeBall.position);
|
||||||
calculateBallQuad(&fakeBall, &childFace);
|
calculateBallQuad(&fakeBall, &childFace);
|
||||||
drawWallsBetweenQuads(¤tFace, &childFace);
|
drawWallsBetweenQuads(&fakeBall.position, ¤tFace, &childFace);
|
||||||
if (vec3Distance(&ball->position, &fakeBall.position) >=
|
if (vec3Distance(&ball->position, &fakeBall.position) >=
|
||||||
ball->radius) {
|
ball->radius) {
|
||||||
drawQuad(&childFace);
|
drawQuad(&childFace);
|
||||||
|
|
|
@ -573,10 +573,10 @@ int convexHullMergeTriangles(convexHull *hull) {
|
||||||
f1->vertexNum = 4;
|
f1->vertexNum = 4;
|
||||||
f2->vertexNum = 0;
|
f2->vertexNum = 0;
|
||||||
//if (edgeIndex >= 12 && edgeIndex <= 12) {
|
//if (edgeIndex >= 12 && edgeIndex <= 12) {
|
||||||
drawDebugPoint((vec3 *)arrayGetItem(
|
// drawDebugPoint((vec3 *)arrayGetItem(
|
||||||
hull->vertexArray, e->p1), edgeIndex);
|
// hull->vertexArray, e->p1), edgeIndex);
|
||||||
drawDebugPoint((vec3 *)arrayGetItem(
|
// drawDebugPoint((vec3 *)arrayGetItem(
|
||||||
hull->vertexArray, e->p2), edgeIndex);
|
// hull->vertexArray, e->p2), edgeIndex);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue