Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/bullet/Bullet/CollisionShapes/SphereShape.cpp')
-rw-r--r--extern/bullet/Bullet/CollisionShapes/SphereShape.cpp44
1 files changed, 30 insertions, 14 deletions
diff --git a/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp b/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp
index 182b458ec7b..6afb0fe5091 100644
--- a/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp
+++ b/extern/bullet/Bullet/CollisionShapes/SphereShape.cpp
@@ -17,42 +17,58 @@
SphereShape ::SphereShape (SimdScalar radius)
: m_radius(radius)
-{
- SetMargin( radius );
+{
}
SimdVector3 SphereShape::LocalGetSupportingVertexWithoutMargin(const SimdVector3& vec)const
{
- return SimdVector3(0.f,0.f,0.f);
-}
+ float radius = m_radius - GetMargin();
-SimdVector3 SphereShape::LocalGetSupportingVertex(const SimdVector3& vec)const
-{
SimdScalar len = vec.length2();
if (fabsf(len) < 0.0001f)
{
- return SimdVector3(GetMargin(),GetMargin(),GetMargin());
+ return SimdVector3(m_localScaling[0] * radius,m_localScaling[1]*radius,m_localScaling[2]*radius);
}
- return vec * (GetMargin() / sqrtf(len));
+ return vec * (m_localScaling*(radius / sqrtf(len)));
}
+SimdVector3 SphereShape::LocalGetSupportingVertex(const SimdVector3& vec)const
+{
+ SimdVector3 supVertex;
+ supVertex = LocalGetSupportingVertexWithoutMargin(vec);
+ if ( GetMargin()!=0.f )
+ {
+ SimdVector3 vecnorm = vec;
+ if (vecnorm .length2() == 0.f)
+ {
+ vecnorm.setValue(-1.f,-1.f,-1.f);
+ }
+ vecnorm.normalize();
+ supVertex+= GetMargin() * vecnorm;
+ }
+ return supVertex;
+}
+
+/*
+//broken due to scaling
void SphereShape::GetAabb(const SimdTransform& t,SimdVector3& aabbMin,SimdVector3& aabbMax) const
{
const SimdVector3& center = t.getOrigin();
- SimdScalar radius = m_radius + CONVEX_DISTANCE_MARGIN;
- radius += 1;
-
- const SimdVector3 extent(radius,radius,radius);
+ SimdScalar radius = m_radius;
+
+ SimdVector3 extent = m_localScaling*radius;
+ extent+= SimdVector3(GetMargin(),GetMargin(),GetMargin());
aabbMin = center - extent;
aabbMax = center + extent;
}
-
+*/
void SphereShape::CalculateLocalInertia(SimdScalar mass,SimdVector3& inertia)
{
- SimdScalar elem = 0.4f * mass * m_radius*m_radius;
+ SimdScalar elem = 0.4f * mass * m_radius*m_radius;
inertia[0] = inertia[1] = inertia[2] = elem;
+
} \ No newline at end of file