use extension
This commit is contained in:
parent
7437a45372
commit
47a2c12160
@ -44,15 +44,17 @@ struct b3QHull : public b3Hull
|
||||
|
||||
// Create a convex hull from an array of points.
|
||||
// If the creation has failed then this convex hull is not modified.
|
||||
// Use the flag simplify to tell the convex hull creation code to simplify the convex hull after
|
||||
// construction.
|
||||
// If the flag simplify is set to true then the convex hull is simplified after
|
||||
// initial construction.
|
||||
void Set(const b3Vec3* points, u32 count, bool simplify = true);
|
||||
|
||||
// Set this hull as a cylinder located at the origin.
|
||||
void SetAsCylinder(float32 radius = 1.0f, float32 height = 1.0f);
|
||||
// Set this hull as a cylinder located at the origin
|
||||
// given the radius and extent along the y axis.
|
||||
void SetAsCylinder(float32 radius = 1.0f, float32 ey = 1.0f);
|
||||
|
||||
// Set this hull as a cone located at the origin.
|
||||
void SetAsCone(float32 radius = 1.0f, float32 height = 1.0f);
|
||||
// Set this hull as a cone located at the origin
|
||||
// given the radius and extent along the y axis.
|
||||
void SetAsCone(float32 radius = 1.0f, float32 ey = 1.0f);
|
||||
};
|
||||
|
||||
#endif
|
@ -409,10 +409,10 @@ void b3QHull::Set(const b3Vec3* points, u32 count, bool simplify)
|
||||
centroid = b3ComputeCentroid(this);
|
||||
}
|
||||
|
||||
void b3QHull::SetAsCylinder(float32 radius, float32 height)
|
||||
void b3QHull::SetAsCylinder(float32 radius, float32 ey)
|
||||
{
|
||||
B3_ASSERT(radius > 0.0f);
|
||||
B3_ASSERT(height > 0.0f);
|
||||
B3_ASSERT(ey > 0.0f);
|
||||
|
||||
const u32 kEdgeCount = 20;
|
||||
const u32 kVertexCount = 4 * kEdgeCount;
|
||||
@ -424,7 +424,7 @@ void b3QHull::SetAsCylinder(float32 radius, float32 height)
|
||||
b3Quat q = b3QuatRotationY(kAngleInc);
|
||||
|
||||
{
|
||||
b3Vec3 center(0.0f, -0.5f * height, 0.0f);
|
||||
b3Vec3 center(0.0f, -ey, 0.0f);
|
||||
b3Vec3 n1(1.0f, 0.0f, 0.0f);
|
||||
b3Vec3 v1 = center + radius * n1;
|
||||
for (u32 i = 0; i < kEdgeCount; ++i)
|
||||
@ -441,7 +441,7 @@ void b3QHull::SetAsCylinder(float32 radius, float32 height)
|
||||
}
|
||||
|
||||
{
|
||||
b3Vec3 center(0.0f, 0.5f * height, 0.0f);
|
||||
b3Vec3 center(0.0f, ey, 0.0f);
|
||||
b3Vec3 n1(1.0f, 0.0f, 0.0f);
|
||||
b3Vec3 v1 = center + radius * n1;
|
||||
for (u32 i = 0; i < kEdgeCount; ++i)
|
||||
@ -461,10 +461,10 @@ void b3QHull::SetAsCylinder(float32 radius, float32 height)
|
||||
Set(vs, count, false);
|
||||
}
|
||||
|
||||
void b3QHull::SetAsCone(float32 radius, float32 height)
|
||||
void b3QHull::SetAsCone(float32 radius, float32 ey)
|
||||
{
|
||||
B3_ASSERT(radius > 0.0f);
|
||||
B3_ASSERT(height > 0.0f);
|
||||
B3_ASSERT(ey > 0.0f);
|
||||
|
||||
const u32 kEdgeCount = 20;
|
||||
const u32 kVertexCount = 2 * kEdgeCount + 1;
|
||||
@ -475,7 +475,7 @@ void b3QHull::SetAsCone(float32 radius, float32 height)
|
||||
float32 kAngleInc = 2.0f * B3_PI / float32(kEdgeCount);
|
||||
b3Quat q = b3QuatRotationY(kAngleInc);
|
||||
|
||||
b3Vec3 center(0.0f, -0.5f * height, 0.0f);
|
||||
b3Vec3 center(0.0f, -ey, 0.0f);
|
||||
b3Vec3 n1(1.0f, 0.0f, 0.0f);
|
||||
b3Vec3 v1 = center + radius * n1;
|
||||
for (u32 i = 0; i < kEdgeCount; ++i)
|
||||
@ -490,7 +490,7 @@ void b3QHull::SetAsCone(float32 radius, float32 height)
|
||||
v1 = v2;
|
||||
}
|
||||
|
||||
vs[count++].Set(0.0f, 0.5f * height, 0.0f);
|
||||
vs[count++].Set(0.0f, ey, 0.0f);
|
||||
|
||||
// Set
|
||||
Set(vs, count, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user