|
|
@ -207,21 +207,21 @@ public: |
|
|
|
tree.structure.push_back(blob0); |
|
|
|
|
|
|
|
algoim::organizer::Blob blob1; |
|
|
|
blob0.isPrimitive = 1; |
|
|
|
blob0.nodeOp = 0; |
|
|
|
blob0.inOut = 0; |
|
|
|
blob0.oneChildInOut = 0; |
|
|
|
blob0.isLeft = 0; |
|
|
|
blob0.ancestor = 0; |
|
|
|
blob1.isPrimitive = 1; |
|
|
|
blob1.nodeOp = 0; |
|
|
|
blob1.inOut = 0; |
|
|
|
blob1.oneChildInOut = 0; |
|
|
|
blob1.isLeft = 0; |
|
|
|
blob1.ancestor = 0; |
|
|
|
tree.structure.push_back(blob1); |
|
|
|
|
|
|
|
algoim::organizer::Blob blob2; |
|
|
|
blob0.isPrimitive = 0; |
|
|
|
blob0.nodeOp = 3; // no set
|
|
|
|
blob0.inOut = 0; |
|
|
|
blob0.oneChildInOut = 0; |
|
|
|
blob0.isLeft = 0; |
|
|
|
blob0.ancestor = 0; |
|
|
|
blob2.isPrimitive = 0; |
|
|
|
blob2.nodeOp = 3; // no set
|
|
|
|
blob2.inOut = 0; |
|
|
|
blob2.oneChildInOut = 0; |
|
|
|
blob2.isLeft = 0; |
|
|
|
blob2.ancestor = 0; |
|
|
|
tree.structure.push_back(blob2); |
|
|
|
|
|
|
|
tree.primitiveNodeIdx.push_back(0); |
|
|
@ -540,7 +540,7 @@ public: |
|
|
|
result.tensors[0] = cylinder.tensors[0]; |
|
|
|
result.aabb = cylinder.aabb; |
|
|
|
result.subBlobTree.primitiveNodeIdx.push_back(0); |
|
|
|
result.subBlobTree.structure.push_back(algoim::organizer::Blob{1, 2, 0, 0, 0, 0}); |
|
|
|
result.subBlobTree.structure.push_back(algoim::organizer::Blob{1, 0, 0, 0, 0, 0}); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
@ -665,8 +665,8 @@ public: |
|
|
|
|
|
|
|
auto halfPlane1 = createHalfPlane(points[0], -normal); |
|
|
|
auto halfPlane2 = createHalfPlane(points[0] + extusion, normal); |
|
|
|
result = this->unionNode(result, halfPlane1); |
|
|
|
result = this->unionNode(result, halfPlane2); |
|
|
|
result = this->intersectNode(result, halfPlane1); |
|
|
|
result = this->intersectNode(result, halfPlane2); |
|
|
|
|
|
|
|
this->m_allVisible.push_back(result); |
|
|
|
return this->m_allVisible.size() - 1; |
|
|
@ -719,36 +719,38 @@ public: |
|
|
|
double sinHalfTheta = 2 * bulge / (1 + bulge * bulge); |
|
|
|
double radius = halfDistance / sinHalfTheta; |
|
|
|
double scalar = std::sqrt(radius * radius - halfDistance * halfDistance); |
|
|
|
auto origion = middlePoint + middleToOrigion * scalar; |
|
|
|
|
|
|
|
/* Determine whether to merge or subtract */ |
|
|
|
/* The operation is merge if flag is true, otherwise it is subtract */ |
|
|
|
bool flag; |
|
|
|
/* */ |
|
|
|
auto centroidPoint = computePolygonCentroid(points); |
|
|
|
auto middleToCentroid = Direction3D(centroidPoint - middlePoint); |
|
|
|
/* out */ |
|
|
|
if (middleToCentroid.dot(middleToOrigion) > 0.0) |
|
|
|
{ |
|
|
|
if (bulge > 0.0) |
|
|
|
{ |
|
|
|
flag = true; |
|
|
|
} |
|
|
|
else |
|
|
|
/* |bulge| > 1 */ |
|
|
|
if (std::abs(bulge) > 1.0 + 1e-8) |
|
|
|
{ |
|
|
|
flag = false; |
|
|
|
scalar *= -1; |
|
|
|
} |
|
|
|
|
|
|
|
flag = true; |
|
|
|
} |
|
|
|
/* in */ |
|
|
|
else |
|
|
|
{ |
|
|
|
if (bulge > 0.0) |
|
|
|
{ |
|
|
|
flag = false; |
|
|
|
} |
|
|
|
else |
|
|
|
/* |bulge| > 1 */ |
|
|
|
if (std::abs(bulge) > 1.0 + 1e-8) |
|
|
|
{ |
|
|
|
flag = true; |
|
|
|
scalar *= -1; |
|
|
|
} |
|
|
|
|
|
|
|
flag = false; |
|
|
|
} |
|
|
|
|
|
|
|
Point3D origion = middlePoint + middleToOrigion * scalar; |
|
|
|
|
|
|
|
/* Determine which axis is aligned */ |
|
|
|
int alignAxis; |
|
|
|
if (normal.isParallel(Direction3D(1, 0, 0))) |
|
|
@ -792,13 +794,13 @@ public: |
|
|
|
|
|
|
|
auto halfPlane1 = createHalfPlane(points[0], -normal); |
|
|
|
auto halfPlane2 = createHalfPlane(points[0] + extusion, normal); |
|
|
|
base = this->unionNode(base, halfPlane1); |
|
|
|
base = this->unionNode(base, halfPlane2); |
|
|
|
base = this->intersectNode(base, halfPlane1); |
|
|
|
base = this->intersectNode(base, halfPlane2); |
|
|
|
|
|
|
|
for (size_t i = 0; i < base.aabbs.size(); i++) |
|
|
|
{ |
|
|
|
for (size_t i = 0; i < base.aabbs.size(); i++) |
|
|
|
{ |
|
|
|
base.aabbs[i] = base.aabb; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this->m_allVisible.push_back(base); |
|
|
|
|
|
|
|