Added btUniformScalingShape (including support for debug rendering etc)
This allows to re-use a convex shape, while each instance can re-scale it (with a uniform scalar factor)
This commit is contained in:
@@ -23,6 +23,7 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
|
||||
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
@@ -449,8 +450,13 @@ void DemoApplication::shootBox(const btVector3& destination)
|
||||
startTransform.setIdentity();
|
||||
btVector3 camPos = getCameraPosition();
|
||||
startTransform.setOrigin(camPos);
|
||||
//btCollisionShape* boxShape = new btSphereShape(1);
|
||||
btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f));
|
||||
//#define TEST_UNIFORM_SCALING_SHAPE 1
|
||||
#ifdef TEST_UNIFORM_SCALING_SHAPE
|
||||
btConvexShape* childShape = new btBoxShape(btVector3(1.f,1.f,1.f));
|
||||
btUniformScalingShape* boxShape = new btUniformScalingShape(childShape,0.5f);
|
||||
#else
|
||||
btCollisionShape* boxShape = new btSphereShape(1);
|
||||
#endif//
|
||||
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,boxShape);
|
||||
|
||||
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
|
||||
|
||||
@@ -38,6 +38,8 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
|
||||
|
||||
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
@@ -313,6 +315,23 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
glPushMatrix();
|
||||
btglMultMatrix(m);
|
||||
|
||||
if (shape->getShapeType() == UNIFORM_SCALING_SHAPE_PROXYTYPE)
|
||||
{
|
||||
const btUniformScalingShape* scalingShape = static_cast<const btUniformScalingShape*>(shape);
|
||||
const btConvexShape* convexShape = scalingShape->getChildShape();
|
||||
float scalingFactor = (float)scalingShape->getUniformScalingFactor();
|
||||
{
|
||||
btScalar tmpScaling[4][4]={scalingFactor,0,0,0,
|
||||
0,scalingFactor,0,0,
|
||||
0,0,scalingFactor,0,
|
||||
0,0,0,1};
|
||||
|
||||
drawOpenGL( (btScalar*)tmpScaling,convexShape,color,debugMode);
|
||||
}
|
||||
glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
|
||||
{
|
||||
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
|
||||
|
||||
@@ -21,7 +21,13 @@ Written by: Marten Svanfeldt
|
||||
#include "GlutStuff.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "RagdollDemo.h"
|
||||
|
||||
GLDebugDrawer debugDrawer;
|
||||
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#define M_PI_4 0.785398163397448309616
|
||||
@@ -311,6 +317,8 @@ void RagdollDemo::initPhysics()
|
||||
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,overlappingPairCache,solver);
|
||||
|
||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
||||
|
||||
// Setup a big ground box
|
||||
{
|
||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(200.),btScalar(10.),btScalar(200.)));
|
||||
|
||||
Reference in New Issue
Block a user