Apply convex hull on key ball.

master
Jeremy Hu 2017-01-02 23:05:19 +09:30
parent 026ef777af
commit 76ef1bed33
1 changed files with 13 additions and 2 deletions

View File

@ -11,6 +11,7 @@
#include "draw.h" #include "draw.h"
#define BMESH_MAX_PARENT_BALL_DEPTH 1000 #define BMESH_MAX_PARENT_BALL_DEPTH 1000
#define BMESH_INTVAL_DIST_DIV 10
typedef struct bmeshBallIndex { typedef struct bmeshBallIndex {
int ballIndex; int ballIndex;
@ -246,7 +247,7 @@ static int bmeshGenerateInbetweenBallsBetween(bmesh *bm,
generateYZfromBoneDirection(&boneDirection, generateYZfromBoneDirection(&boneDirection,
&localYaxis, &localZaxis); &localYaxis, &localZaxis);
intvalDist = (firstBall->radius + secondBall->radius) / 3; intvalDist = (firstBall->radius + secondBall->radius) / BMESH_INTVAL_DIST_DIV;
step = intvalDist; step = intvalDist;
distance = vec3Length(&boneDirection); distance = vec3Length(&boneDirection);
if (distance > intvalDist) { if (distance > intvalDist) {
@ -551,6 +552,15 @@ static convexHull *createConvexHullForBall(bmesh *bm, int depth,
arrayDestroy(ballPtrArray); arrayDestroy(ballPtrArray);
return 0; return 0;
} }
if (BMESH_BALL_TYPE_KEY == ball->type) {
if (-1 == addBallToHull(hull, ball,
&outmostBall, &outmostBallFirstVertexIndex)) {
fprintf(stderr, "%s:addBallToHull failed.\n", __FUNCTION__);
arrayDestroy(ballPtrArray);
convexHullDestroy(hull);
return 0;
}
}
for (child = bmeshGetBallFirstChild(bm, ball, &iterator); for (child = bmeshGetBallFirstChild(bm, ball, &iterator);
child; child;
child = bmeshGetBallNextChild(bm, ball, &iterator)) { child = bmeshGetBallNextChild(bm, ball, &iterator)) {
@ -660,7 +670,8 @@ static int bmeshStichFrom(bmesh *bm, int depth, bmeshBall *ball) {
bm->parentBallStack[depth] = ball; bm->parentBallStack[depth] = ball;
} }
ball->roundColor = bm->roundColor; ball->roundColor = bm->roundColor;
if (BMESH_BALL_TYPE_ROOT == ball->type) { if (BMESH_BALL_TYPE_ROOT == ball->type ||
BMESH_BALL_TYPE_KEY == ball->type) {
convexHull *hull = 0; convexHull *hull = 0;
for (;;) { for (;;) {