Merge remote-tracking branch 'origin/master' into render_kart_driver_differently

This commit is contained in:
Benau 2016-06-28 14:56:21 +08:00
commit 984553fd33
5 changed files with 68 additions and 2 deletions

View File

@ -17,6 +17,9 @@ subject to the following restrictions:
#include "SphereTriangleDetector.h"
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
#include "BulletCollision/CollisionShapes/btSphereShape.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold)
@ -43,6 +46,35 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Res
if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold))
{
// In some cases the normalInB is incorrect with a static triangle
// mesh (i.e. it's the connection point between puck and triangle, not
// the normal from the triangle - which is fine if the triangle mesh
// is a dynamic rigid body (i.e. can be pushed away), but appears to
// be wrong in case of a static body - it causes #2522 (puck suddenly
// pushed in air). So in case of a static triangle mesh, recompute
// the normal just based on the triangle mesh:
const btManifoldResult *mani = dynamic_cast<btManifoldResult*>(&output);
if(mani)
{
// Find the triangle:
const btCollisionObject *co = mani->getBody0Internal();
const btTriangleShape *tri = dynamic_cast<const btTriangleShape*>(co->getCollisionShape());
if(!tri)
{
co = mani->getBody1Internal();
tri = dynamic_cast<const btTriangleShape*>(co->getCollisionShape());
}
// If we have a triangle and it is static, recompute the normal
if(tri && co->isStaticOrKinematicObject())
{
normal = (tri->m_vertices1[1]-tri->m_vertices1[0])
.cross(tri->m_vertices1[2]-tri->m_vertices1[0]);
normal.normalize();;
}
}
if (swapResults)
{
btVector3 normalOnB = transformB.getBasis()*normal;

View File

@ -17,6 +17,9 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btConvexShape.h"
#include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h"
#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
@ -441,6 +444,32 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu
m_cachedSeparatingAxis = normalInB;
m_cachedSeparatingDistance = distance;
// In some cases the normalInB is incorrect with a static triangle
// mesh (i.e. it's the connection point between puck and triangle, not
// the normal from the triangle - which is fine if the triangle mesh
// is a dynamic rigid body (i.e. can be pushed away), but appears to
// be wrong in case of a static body - it causes #2522 (puck suddenly
// pushed in air). So in case of a static triangle mesh, recompute
// the normal just based on the triangle mesh:
const btManifoldResult *mani = dynamic_cast<btManifoldResult*>(&output);
if(mani)
{
// Find the triangle:
const btCollisionObject *co = mani->getBody0Internal();
const btTriangleShape *tri = dynamic_cast<const btTriangleShape*>(co->getCollisionShape());
if(!tri)
{
co = mani->getBody1Internal();
tri = dynamic_cast<const btTriangleShape*>(co->getCollisionShape());
}
// If we have a triangle and it is static, recompute the normal
if(tri && co->isStaticOrKinematicObject())
{
normalInB = (tri->m_vertices1[1]-tri->m_vertices1[0])
.cross(tri->m_vertices1[2]-tri->m_vertices1[0]);
normalInB.normalize();;
}
}
output.addContactPoint(
normalInB,
pointOnB+positionOffset,

View File

@ -490,6 +490,7 @@ bool DeviceManager::load()
if(input->getName()!="input")
{
Log::warn("DeviceManager", "Invalid input.xml file - no input node.");
delete input;
return false;
}
@ -500,6 +501,7 @@ bool DeviceManager::load()
GUIEngine::showMessage(_("Please re-configure your key bindings."));
GUIEngine::showMessage(_("Your input config file is not compatible "
"with this version of STK."));
delete input;
return false;
}

View File

@ -191,8 +191,10 @@ Online::XMLRequest* ServersManager::getLANRefreshRequest() const
m_success = true;
} // if received_data
} // while still waiting
if (!m_success)
m_info = _("No LAN server detected");
delete broadcast;
if (!m_success)
m_info = _("No LAN server detected");
} // operation
// --------------------------------------------------------------------
/** This function is necessary, otherwise the XML- and HTTP-Request

View File

@ -46,6 +46,7 @@ NavMesh::NavMesh(const std::string &filename)
if(xml->getName()!="navmesh")
{
Log::error("NavMesh", "NavMesh is invalid. \n");
delete xml;
return;
}