Fixed bug in bevel shape: the bevel shaped was larger than the bounding

box of the chassis, resulting in collisions caused by the invisible
bevelled part of the chassis.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10469 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-12-21 21:43:01 +00:00
parent 5322baa0f4
commit 5a41379479
2 changed files with 16 additions and 14 deletions

View File

@ -292,16 +292,18 @@
the orientation - if a kart is pushed in the direction it is
driving, it will be more (no friction from tires), while when
pushed to the side, hardly anything happens.
bevel-factor: the X and Y coordinate of each point of the kart
chassis (box) are multiplied with (1-bevelX) and (1-bevelY),
and the Z coordinate is multiplied with (1+bevelZ). The
resulting point is then added to the chassis collision shape.
This gives a bevelled box shape. A value of 0 for all bevel
coordinates disables bevelling, and uses a simple box shape.
bevel-factor: for each point of the chassis collision box one
additional point is added, resulting in a bevelled box shape.
The original Z coordinate of the chassis is multiplied by
1-bevelZ (i.e. the main box part of the shape is shortened).
The bevel point has the original Z coordinate, and the X and
Y coordinates of the box are multiplied with (1-bevelX) and
(1-bevelY). A value of 0 for all bevel coordinates disables
bevelling, and uses a simple box shape.
As an example, a value of 1 for x and z will result in a
sharp 'arrow' like shape. -->
<collision impulse="150" impulse-time="0.1" side-impulse="600"
restitution="1.0" bevel-factor="0 0 0" />
restitution="1.0" bevel-factor="0.3 0.3 0.3" />
<!-- Kart-specific plunger and rubber band handling: max-length is
the maximum length of rubber band before it snaps. force is

View File

@ -247,9 +247,10 @@ void Kart::createPhysics()
const Vec3 &bevel = m_kart_properties->getBevelFactor();
if(bevel.getX() || bevel.getY() || bevel.getZ())
{
Vec3 orig_factor(1, 1, 1-bevel.getZ());
Vec3 bevel_factor(1.0f-bevel.getX(),
1.0f-bevel.getY(),
1.0f+bevel.getZ() );
1.0f );
btConvexHullShape *hull = new btConvexHullShape();
for(int x=-1; x<=1; x+=2)
{
@ -257,13 +258,12 @@ void Kart::createPhysics()
{
for(int z=-1; z<=1; z+=2)
{
btVector3 p(x*getKartModel()->getWidth() *0.5f,
Vec3 p(x*getKartModel()->getWidth()*0.5f,
y*getKartModel()->getHeight()*0.5f,
z*getKartModel()->getLength()*0.5f);
hull->addPoint(p);
p *= bevel_factor;
hull->addPoint(p);
hull->addPoint(p*orig_factor);
hull->addPoint(p*bevel_factor);
} // for z
} // for y
} // for x