free memory for btShapeHulls, keep track of it in GL_ShapeDrawer.
move btShapeHull and btConvexHull into its own library in Extras/ConvexHull (it allocates memory using mem/delete and refactoring into using btAlignedAlloc/Free takes too much time) fix heightfield / btOptimizedBvh for quantization, so that raycast can use quantized aabb (clamp up for maxima and down for minima) work-in-progress (update projectfiles etc)
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
#include "GLDebugDrawer.h"
|
#include "GLDebugDrawer.h"
|
||||||
|
|
||||||
static GLDebugDrawer gDebugDrawer;
|
|
||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ DemoApplication* CreatDemo(btDemoEntry* entry)
|
|||||||
btAssert(demo);
|
btAssert(demo);
|
||||||
if (demo->getDynamicsWorld())
|
if (demo->getDynamicsWorld())
|
||||||
{
|
{
|
||||||
demo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
demo->getDynamicsWorld()->setDebugDrawer(new GLDebugDrawer());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BT_NO_PROFILE
|
#ifndef BT_NO_PROFILE
|
||||||
@@ -168,6 +167,8 @@ void SimulationLoop()
|
|||||||
if (testSelection != testIndex)
|
if (testSelection != testIndex)
|
||||||
{
|
{
|
||||||
testIndex = testSelection;
|
testIndex = testSelection;
|
||||||
|
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer())
|
||||||
|
delete demo->getDynamicsWorld()->getDebugDrawer();
|
||||||
delete demo;
|
delete demo;
|
||||||
entry = g_demoEntries + testIndex;
|
entry = g_demoEntries + testIndex;
|
||||||
demo = CreatDemo(entry);
|
demo = CreatDemo(entry);
|
||||||
@@ -192,6 +193,8 @@ void Keyboard(unsigned char key, int x, int y)
|
|||||||
|
|
||||||
// Press 'r' to reset.
|
// Press 'r' to reset.
|
||||||
case 'r':
|
case 'r':
|
||||||
|
if (demo->getDynamicsWorld()->getDebugDrawer())
|
||||||
|
delete demo->getDynamicsWorld()->getDebugDrawer();
|
||||||
delete demo;
|
delete demo;
|
||||||
demo = CreatDemo(entry);
|
demo = CreatDemo(entry);
|
||||||
Resize(width,height);
|
Resize(width,height);
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ void CollisionDemo::displayCallback(void) {
|
|||||||
|
|
||||||
tr[i].getOpenGLMatrix( m );
|
tr[i].getOpenGLMatrix( m );
|
||||||
|
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ void CollisionDemo::displayCallback(void) {
|
|||||||
btTransform ident;
|
btTransform ident;
|
||||||
ident.setIdentity();
|
ident.setIdentity();
|
||||||
ident.getOpenGLMatrix(m);
|
ident.getOpenGLMatrix(m);
|
||||||
GL_ShapeDrawer::drawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
|
||||||
|
|
||||||
|
|
||||||
btQuaternion orn;
|
btQuaternion orn;
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ void CollisionInterfaceDemo::displayCallback(void) {
|
|||||||
{
|
{
|
||||||
|
|
||||||
objects[i].getWorldTransform().getOpenGLMatrix( m );
|
objects[i].getWorldTransform().getOpenGLMatrix( m );
|
||||||
GL_ShapeDrawer::drawOpenGL(m,objects[i].getCollisionShape(),btVector3(1,1,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,objects[i].getCollisionShape(),btVector3(1,1,1),getDebugMode());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
|||||||
/*for (i=0;i<numObjects;i++)
|
/*for (i=0;i<numObjects;i++)
|
||||||
{
|
{
|
||||||
fromTrans[i].getOpenGLMatrix( m );
|
fromTrans[i].getOpenGLMatrix( m );
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
|
m_shapeDrawer.drawOpenGL(m,shapePtr[i]);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -171,13 +171,13 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
|||||||
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans);
|
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans);
|
||||||
|
|
||||||
//fromTrans[i].getOpenGLMatrix(m);
|
//fromTrans[i].getOpenGLMatrix(m);
|
||||||
//GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
|
//m_shapeDrawer.drawOpenGL(m,shapePtr[i]);
|
||||||
|
|
||||||
//toTrans[i].getOpenGLMatrix(m);
|
//toTrans[i].getOpenGLMatrix(m);
|
||||||
//GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
|
//m_shapeDrawer.drawOpenGL(m,shapePtr[i]);
|
||||||
|
|
||||||
interpolatedTrans.getOpenGLMatrix( m );
|
interpolatedTrans.getOpenGLMatrix( m );
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,10 +229,10 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
|||||||
for (i=0;i<numObjects;i++)
|
for (i=0;i<numObjects;i++)
|
||||||
{
|
{
|
||||||
fromTrans[i].getOpenGLMatrix(m);
|
fromTrans[i].getOpenGLMatrix(m);
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
btDebugCastResult rayResult1(fromTrans[0],shapePtr[0],linVels[0],angVels[0]);
|
btDebugCastResult rayResult1(fromTrans[0],shapePtr[0],linVels[0],angVels[0],&m_shapeDrawer);
|
||||||
|
|
||||||
|
|
||||||
for (i=1;i<numObjects;i++)
|
for (i=1;i<numObjects;i++)
|
||||||
@@ -267,12 +267,12 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
|
|||||||
btTransformUtil::integrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans);
|
btTransformUtil::integrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans);
|
||||||
|
|
||||||
hitTrans.getOpenGLMatrix(m);
|
hitTrans.getOpenGLMatrix(m);
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode());
|
||||||
|
|
||||||
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans);
|
btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans);
|
||||||
|
|
||||||
hitTrans.getOpenGLMatrix(m);
|
hitTrans.getOpenGLMatrix(m);
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btQuickprof.h"
|
#include "LinearMath/btQuickprof.h"
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
#include "LinearMath/btIDebugDraw.h"
|
||||||
#include "LinearMath/btGeometryUtil.h"
|
#include "LinearMath/btGeometryUtil.h"
|
||||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
#include "btShapeHull.h"
|
||||||
|
|
||||||
//#define USE_PARALLEL_DISPATCHER 1
|
//#define USE_PARALLEL_DISPATCHER 1
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
#ifdef USE_PARALLEL_DISPATCHER
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ void DoublePrecisionDemo::displayCallback(void)
|
|||||||
temp = objects[i].getWorldTransform();
|
temp = objects[i].getWorldTransform();
|
||||||
temp.setOrigin(temp.getOrigin() - m_cameraPosition);
|
temp.setOrigin(temp.getOrigin() - m_cameraPosition);
|
||||||
temp.getOpenGLMatrix( m );
|
temp.getOpenGLMatrix( m );
|
||||||
GL_ShapeDrawer::drawOpenGL(m,objects[i].getCollisionShape(),color,getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,objects[i].getCollisionShape(),color,getDebugMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
objects[1].getWorldTransform().setOrigin(objects[1].getWorldTransform().getOrigin()+btVector3(-VERY_SMALL_INCREMENT,-VERY_SMALL_INCREMENT,0));
|
objects[1].getWorldTransform().setOrigin(objects[1].getWorldTransform().getOrigin()+btVector3(-VERY_SMALL_INCREMENT,-VERY_SMALL_INCREMENT,0));
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ void GimpactConcaveDemo::renderme()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_ShapeDrawer::drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ void LinearConvexCastDemo::displayCallback(void)
|
|||||||
tr[ 0 ].getOpenGLMatrix( m1 );
|
tr[ 0 ].getOpenGLMatrix( m1 );
|
||||||
tr[ 1 ].getOpenGLMatrix( m2 );
|
tr[ 1 ].getOpenGLMatrix( m2 );
|
||||||
|
|
||||||
GL_ShapeDrawer::drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 0, 0 ), getDebugMode() );
|
m_shapeDrawer.drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 0, 0 ), getDebugMode() );
|
||||||
GL_ShapeDrawer::drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 0, 0 ), getDebugMode() );
|
m_shapeDrawer.drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 0, 0 ), getDebugMode() );
|
||||||
|
|
||||||
btVector3 originA, originB;
|
btVector3 originA, originB;
|
||||||
originA.setInterpolate3( tr[ 0 ].getOrigin(), toA.getOrigin(), result.m_fraction );
|
originA.setInterpolate3( tr[ 0 ].getOrigin(), toA.getOrigin(), result.m_fraction );
|
||||||
@@ -153,8 +153,8 @@ void LinearConvexCastDemo::displayCallback(void)
|
|||||||
A.getOpenGLMatrix( m1 );
|
A.getOpenGLMatrix( m1 );
|
||||||
B.getOpenGLMatrix( m2 );
|
B.getOpenGLMatrix( m2 );
|
||||||
|
|
||||||
GL_ShapeDrawer::drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 1, 0 ), getDebugMode() );
|
m_shapeDrawer.drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 1, 0 ), getDebugMode() );
|
||||||
GL_ShapeDrawer::drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 1, 0 ), getDebugMode() );
|
m_shapeDrawer.drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 1, 0 ), getDebugMode() );
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
|
|||||||
@@ -1535,7 +1535,7 @@ void ConcaveDemo::renderme()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_ShapeDrawer::drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,10 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
|||||||
const btPolyhedralConvexShape* m_shape;
|
const btPolyhedralConvexShape* m_shape;
|
||||||
btVector3 m_linVel;
|
btVector3 m_linVel;
|
||||||
btVector3 m_angVel;
|
btVector3 m_angVel;
|
||||||
|
GL_ShapeDrawer* m_shapeDrawer;
|
||||||
|
|
||||||
btDebugCastResult(const btTransform& fromTrans,const btPolyhedralConvexShape* shape,
|
btDebugCastResult(const btTransform& fromTrans,const btPolyhedralConvexShape* shape,
|
||||||
const btVector3& linVel,const btVector3& angVel)
|
const btVector3& linVel,const btVector3& angVel,GL_ShapeDrawer* drawer)
|
||||||
:m_fromTrans(fromTrans),
|
:m_fromTrans(fromTrans),
|
||||||
m_shape(shape),
|
m_shape(shape),
|
||||||
m_linVel(linVel),
|
m_linVel(linVel),
|
||||||
@@ -74,8 +75,7 @@ struct btDebugCastResult : public btConvexCast::CastResult
|
|||||||
btTransform hitTrans;
|
btTransform hitTrans;
|
||||||
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
|
||||||
hitTrans.getOpenGLMatrix(m);
|
hitTrans.getOpenGLMatrix(m);
|
||||||
GL_ShapeDrawer::drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
|
m_shapeDrawer->drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -927,7 +927,7 @@ void DemoApplication::renderme()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_ShapeDrawer::drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
|
#include "GL_ShapeDrawer.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -37,7 +38,6 @@ class btTypedConstraint;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DemoApplication
|
class DemoApplication
|
||||||
{
|
{
|
||||||
void displayProfileString(int xOffset,int yStart,char* message);
|
void displayProfileString(int xOffset,int yStart,char* message);
|
||||||
@@ -81,6 +81,7 @@ class DemoApplication
|
|||||||
|
|
||||||
void showProfileInfo(float& xOffset,float& yStart, float yIncr);
|
void showProfileInfo(float& xOffset,float& yStart, float yIncr);
|
||||||
|
|
||||||
|
GL_ShapeDrawer m_shapeDrawer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ subject to the following restrictions:
|
|||||||
#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
|
#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
///
|
||||||
|
#include "btShapeHull.h"
|
||||||
|
|
||||||
#include "LinearMath/btTransformUtil.h"
|
#include "LinearMath/btTransformUtil.h"
|
||||||
|
|
||||||
@@ -470,7 +471,12 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
if (!shape->getUserPointer())
|
if (!shape->getUserPointer())
|
||||||
{
|
{
|
||||||
//create a hull approximation
|
//create a hull approximation
|
||||||
btShapeHull* hull = new btShapeHull(convexShape);
|
void* mem = btAlignedAlloc(sizeof(btShapeHull),16);
|
||||||
|
btShapeHull* hull = new(mem) btShapeHull(convexShape);
|
||||||
|
|
||||||
|
///cleanup memory
|
||||||
|
m_shapeHulls.push_back(hull);
|
||||||
|
|
||||||
btScalar margin = shape->getMargin();
|
btScalar margin = shape->getMargin();
|
||||||
hull->buildHull(margin);
|
hull->buildHull(margin);
|
||||||
convexShape->setUserPointer(hull);
|
convexShape->setUserPointer(hull);
|
||||||
@@ -655,3 +661,22 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
|||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GL_ShapeDrawer::GL_ShapeDrawer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GL_ShapeDrawer::~GL_ShapeDrawer()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0;i<m_shapeHulls.size();i++)
|
||||||
|
{
|
||||||
|
btShapeHull* hull = m_shapeHulls[i];
|
||||||
|
hull->~btShapeHull();
|
||||||
|
btAlignedFree(hull);
|
||||||
|
m_shapeHulls[i] = 0;
|
||||||
|
}
|
||||||
|
m_shapeHulls.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,16 +16,26 @@ subject to the following restrictions:
|
|||||||
#define GL_SHAPE_DRAWER_H
|
#define GL_SHAPE_DRAWER_H
|
||||||
|
|
||||||
class btCollisionShape;
|
class btCollisionShape;
|
||||||
|
class btShapeHull;
|
||||||
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
|
|
||||||
/// OpenGL shape drawing
|
/// OpenGL shape drawing
|
||||||
class GL_ShapeDrawer
|
class GL_ShapeDrawer
|
||||||
{
|
{
|
||||||
public:
|
//clean-up memory of dynamically created shape hulls
|
||||||
|
btAlignedObjectArray<btShapeHull*> m_shapeHulls;
|
||||||
|
|
||||||
|
public:
|
||||||
|
GL_ShapeDrawer();
|
||||||
|
|
||||||
|
virtual ~GL_ShapeDrawer();
|
||||||
|
|
||||||
|
///drawOpenGL might allocate temporary memoty, stores pointer in shape userpointer
|
||||||
|
void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
|
||||||
|
|
||||||
static void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
|
|
||||||
static void drawCoordSystem();
|
|
||||||
static void drawCylinder(float radius,float halfHeight, int upAxis);
|
static void drawCylinder(float radius,float halfHeight, int upAxis);
|
||||||
|
static void drawCoordSystem();
|
||||||
};
|
};
|
||||||
|
|
||||||
void OGL_displaylist_register_shape(btCollisionShape * shape);
|
void OGL_displaylist_register_shape(btCollisionShape * shape);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void SimplexDemo::displayCallback()
|
|||||||
transA.getOpenGLMatrix( m );
|
transA.getOpenGLMatrix( m );
|
||||||
|
|
||||||
/// draw the simplex
|
/// draw the simplex
|
||||||
GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
|
||||||
|
|
||||||
/// calculate closest point from simplex to the origin, and draw this vector
|
/// calculate closest point from simplex to the origin, and draw this vector
|
||||||
simplex.calcClosest(m);
|
simplex.calcClosest(m);
|
||||||
|
|||||||
@@ -409,7 +409,7 @@ void VehicleDemo::renderme()
|
|||||||
m_vehicle->updateWheelTransform(i,true);
|
m_vehicle->updateWheelTransform(i,true);
|
||||||
//draw wheels (cylinders)
|
//draw wheels (cylinders)
|
||||||
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
|
m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m);
|
||||||
GL_ShapeDrawer::drawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
|
m_shapeDrawer.drawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ subject to the following restrictions:
|
|||||||
#include "dom/domCOLLADA.h"
|
#include "dom/domCOLLADA.h"
|
||||||
#include "dae/domAny.h"
|
#include "dae/domAny.h"
|
||||||
#include "dom/domConstants.h"
|
#include "dom/domConstants.h"
|
||||||
|
#include "btShapeHull.h"
|
||||||
|
|
||||||
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btCylinderShape.h"
|
#include "BulletCollision/CollisionShapes/btCylinderShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btConeShape.h"
|
#include "BulletCollision/CollisionShapes/btConeShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
|
||||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
|
||||||
#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
|
#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
|
||||||
|
|||||||
@@ -363,8 +363,8 @@ void ProcessConvexConcaveSpuCollision(SpuCollisionPairInput* wuInput, CollisionT
|
|||||||
///quantize query AABB
|
///quantize query AABB
|
||||||
unsigned short int quantizedQueryAabbMin[3];
|
unsigned short int quantizedQueryAabbMin[3];
|
||||||
unsigned short int quantizedQueryAabbMax[3];
|
unsigned short int quantizedQueryAabbMax[3];
|
||||||
lsMemPtr->bvhShapeData.getOptimizedBvh()->quantizeWithClamp(quantizedQueryAabbMin,aabbMin);
|
lsMemPtr->bvhShapeData.getOptimizedBvh()->quantizeWithClamp(quantizedQueryAabbMin,aabbMin,0);
|
||||||
lsMemPtr->bvhShapeData.getOptimizedBvh()->quantizeWithClamp(quantizedQueryAabbMax,aabbMax);
|
lsMemPtr->bvhShapeData.getOptimizedBvh()->quantizeWithClamp(quantizedQueryAabbMax,aabbMax,1);
|
||||||
|
|
||||||
QuantizedNodeArray& nodeArray = lsMemPtr->bvhShapeData.getOptimizedBvh()->getQuantizedNodeArray();
|
QuantizedNodeArray& nodeArray = lsMemPtr->bvhShapeData.getOptimizedBvh()->getQuantizedNodeArray();
|
||||||
//spu_printf("SPU: numNodes = %d\n",nodeArray.size());
|
//spu_printf("SPU: numNodes = %d\n",nodeArray.size());
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
SUBDIRS( glui ConvexDecomposition BulletMultiThreaded BulletColladaConverter LibXML COLLADA_DOM GIMPACTUtils GIMPACT )
|
SUBDIRS( glui ConvexDecomposition ConvexHull BulletMultiThreaded BulletColladaConverter LibXML COLLADA_DOM GIMPACTUtils GIMPACT )
|
||||||
|
|||||||
10
Extras/ConvexHull/CMakeLists.txt
Normal file
10
Extras/ConvexHull/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Extras/ConvexHull
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_LIBRARY(LibConvexHull
|
||||||
|
btConvexHull.h
|
||||||
|
btConvexHull.cpp
|
||||||
|
btShapeHull.cpp
|
||||||
|
btShapeHull.h
|
||||||
|
)
|
||||||
17
Extras/ConvexHull/Jamfile
Normal file
17
Extras/ConvexHull/Jamfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
SubDir TOP Extras ConvexHull ;
|
||||||
|
|
||||||
|
|
||||||
|
Library convexhull : [ Wildcard *.h *.cpp ] : noinstall ;
|
||||||
|
#internal header path to compile convexhull
|
||||||
|
CFlags convexhull : [ FIncludes $(TOP)/Extras/ConvexHull ] ;
|
||||||
|
|
||||||
|
#expose header include path for apps that depend on ConvexHull
|
||||||
|
convexhull.CFLAGS = [ FIncludes $(TOP)/Extras/ConvexHull ] ;
|
||||||
|
#same for msvcgen
|
||||||
|
MsvcGenConfig convexhull.INCDIRS : $(TOP)/Extras/ConvexHull ;
|
||||||
|
|
||||||
|
#for the include paths
|
||||||
|
LibDepends convexhull : bulletcollision ;
|
||||||
|
|
||||||
|
|
||||||
|
#InstallHeader [ Wildcard *.h ] : ConvexHull ;
|
||||||
@@ -196,6 +196,16 @@ class ConvexH
|
|||||||
HalfEdge(){}
|
HalfEdge(){}
|
||||||
HalfEdge(short _ea,unsigned char _v, unsigned char _p):ea(_ea),v(_v),p(_p){}
|
HalfEdge(short _ea,unsigned char _v, unsigned char _p):ea(_ea),v(_v),p(_p){}
|
||||||
};
|
};
|
||||||
|
ConvexH()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
|
~ConvexH()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
btAlignedObjectArray<REAL3> vertices;
|
btAlignedObjectArray<REAL3> vertices;
|
||||||
btAlignedObjectArray<HalfEdge> edges;
|
btAlignedObjectArray<HalfEdge> edges;
|
||||||
btAlignedObjectArray<Plane> facets;
|
btAlignedObjectArray<Plane> facets;
|
||||||
@@ -415,9 +425,9 @@ ConvexH *ConvexHCrop(ConvexH &convex,const Plane &slice)
|
|||||||
int i;
|
int i;
|
||||||
int vertcountunder=0;
|
int vertcountunder=0;
|
||||||
int vertcountover =0;
|
int vertcountover =0;
|
||||||
static btAlignedObjectArray<int> vertscoplanar; // existing vertex members of convex that are coplanar
|
btAlignedObjectArray<int> vertscoplanar; // existing vertex members of convex that are coplanar
|
||||||
vertscoplanar.resize(0);
|
vertscoplanar.resize(0);
|
||||||
static btAlignedObjectArray<int> edgesplit; // existing edges that members of convex that cross the splitplane
|
btAlignedObjectArray<int> edgesplit; // existing edges that members of convex that cross the splitplane
|
||||||
edgesplit.resize(0);
|
edgesplit.resize(0);
|
||||||
|
|
||||||
assert(convex.edges.size()<480);
|
assert(convex.edges.size()<480);
|
||||||
@@ -1164,7 +1174,7 @@ int calchull(btVector3 *verts,int verts_count, int *&tris_out, int &tris_count,i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tris_count = ts.size()/3;
|
tris_count = ts.size()/3;
|
||||||
tris_out = (int*)btAlignedAlloc(sizeof(int)*ts.size(),16);
|
tris_out = (int*)new int[ts.size()];
|
||||||
|
|
||||||
for (i=0;i<ts.size();i++)
|
for (i=0;i<ts.size();i++)
|
||||||
{
|
{
|
||||||
@@ -1216,7 +1226,7 @@ int overhull(Plane *planes,int planes_count,btVector3 *verts, int verts_count,in
|
|||||||
|
|
||||||
assert(AssertIntact(*c));
|
assert(AssertIntact(*c));
|
||||||
//return c;
|
//return c;
|
||||||
faces_out = (int*)btAlignedAlloc(sizeof(int)*(1+c->facets.size()+c->edges.size()),16); // new int[1+c->facets.size()+c->edges.size()];
|
faces_out = (int*)new int[(1+c->facets.size()+c->edges.size())]; // new int[1+c->facets.size()+c->edges.size()];
|
||||||
faces_count_out=0;
|
faces_count_out=0;
|
||||||
i=0;
|
i=0;
|
||||||
faces_out[faces_count_out++]=-1;
|
faces_out[faces_count_out++]=-1;
|
||||||
@@ -1273,7 +1283,7 @@ void ReleaseHull(PHullResult &result)
|
|||||||
{
|
{
|
||||||
if ( result.mIndices )
|
if ( result.mIndices )
|
||||||
{
|
{
|
||||||
btAlignedFree(result.mIndices);
|
delete[]result.mIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.mVcount = 0;
|
result.mVcount = 0;
|
||||||
@@ -1307,7 +1317,7 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
|
|||||||
unsigned int vcount = desc.mVcount;
|
unsigned int vcount = desc.mVcount;
|
||||||
if ( vcount < 8 ) vcount = 8;
|
if ( vcount < 8 ) vcount = 8;
|
||||||
|
|
||||||
btVector3* vsource = (btVector3*) btAlignedAlloc (sizeof(btVector3)*vcount,16);
|
btVector3* vsource = new btVector3[vcount];
|
||||||
|
|
||||||
btVector3 scale;
|
btVector3 scale;
|
||||||
|
|
||||||
@@ -1336,7 +1346,7 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
|
|||||||
{
|
{
|
||||||
|
|
||||||
// re-index triangle mesh so it refers to only used vertices, rebuild a new vertex table.
|
// re-index triangle mesh so it refers to only used vertices, rebuild a new vertex table.
|
||||||
btVector3 *vscratch = (btVector3 *) btAlignedAlloc( sizeof(btVector3)*hr.mVcount,16);
|
btVector3 *vscratch = new btVector3[hr.mVcount];
|
||||||
BringOutYourDead(hr.mVertices,hr.mVcount, vscratch, ovcount, hr.mIndices, hr.mIndexCount );
|
BringOutYourDead(hr.mVertices,hr.mVcount, vscratch, ovcount, hr.mIndices, hr.mIndexCount );
|
||||||
|
|
||||||
ret = QE_OK;
|
ret = QE_OK;
|
||||||
@@ -1345,11 +1355,11 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
|
|||||||
{
|
{
|
||||||
result.mPolygons = false;
|
result.mPolygons = false;
|
||||||
result.mNumOutputVertices = ovcount;
|
result.mNumOutputVertices = ovcount;
|
||||||
result.mOutputVertices = (btVector3 *)btAlignedAlloc( sizeof(btVector3)*ovcount,16);
|
result.mOutputVertices = new btVector3[ovcount];;
|
||||||
result.mNumFaces = hr.mFaceCount;
|
result.mNumFaces = hr.mFaceCount;
|
||||||
result.mNumIndices = hr.mIndexCount;
|
result.mNumIndices = hr.mIndexCount;
|
||||||
|
|
||||||
result.mIndices = (unsigned int *) btAlignedAlloc( sizeof(unsigned int)*hr.mIndexCount,16);
|
result.mIndices = new unsigned int[hr.mIndexCount];
|
||||||
|
|
||||||
memcpy(result.mOutputVertices, vscratch, sizeof(btVector3)*ovcount );
|
memcpy(result.mOutputVertices, vscratch, sizeof(btVector3)*ovcount );
|
||||||
|
|
||||||
@@ -1378,10 +1388,10 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
|
|||||||
{
|
{
|
||||||
result.mPolygons = true;
|
result.mPolygons = true;
|
||||||
result.mNumOutputVertices = ovcount;
|
result.mNumOutputVertices = ovcount;
|
||||||
result.mOutputVertices = (btVector3 *)btAlignedAlloc( sizeof(btVector3)*ovcount,16);
|
result.mOutputVertices = new btVector3[ovcount];
|
||||||
result.mNumFaces = hr.mFaceCount;
|
result.mNumFaces = hr.mFaceCount;
|
||||||
result.mNumIndices = hr.mIndexCount+hr.mFaceCount;
|
result.mNumIndices = hr.mIndexCount+hr.mFaceCount;
|
||||||
result.mIndices = (unsigned int *) btAlignedAlloc( sizeof(unsigned int)*result.mNumIndices,16);
|
result.mIndices = new unsigned int[result.mNumIndices];
|
||||||
memcpy(result.mOutputVertices, vscratch, sizeof(btVector3)*ovcount );
|
memcpy(result.mOutputVertices, vscratch, sizeof(btVector3)*ovcount );
|
||||||
|
|
||||||
if ( 1 )
|
if ( 1 )
|
||||||
@@ -1412,14 +1422,14 @@ HullError HullLibrary::CreateConvexHull(const HullDesc &desc, //
|
|||||||
ReleaseHull(hr);
|
ReleaseHull(hr);
|
||||||
if ( vscratch )
|
if ( vscratch )
|
||||||
{
|
{
|
||||||
btAlignedFree(vscratch);
|
delete[] vscratch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( vsource )
|
if ( vsource )
|
||||||
{
|
{
|
||||||
btAlignedFree(vsource);
|
delete[] vsource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1432,12 +1442,12 @@ HullError HullLibrary::ReleaseResult(HullResult &result) // release memory alloc
|
|||||||
{
|
{
|
||||||
if ( result.mOutputVertices )
|
if ( result.mOutputVertices )
|
||||||
{
|
{
|
||||||
btAlignedFree(result.mOutputVertices);
|
delete[] result.mOutputVertices;
|
||||||
result.mOutputVertices = 0;
|
result.mOutputVertices = 0;
|
||||||
}
|
}
|
||||||
if ( result.mIndices )
|
if ( result.mIndices )
|
||||||
{
|
{
|
||||||
btAlignedFree(result.mIndices);
|
delete[] result.mIndices;
|
||||||
result.mIndices = 0;
|
result.mIndices = 0;
|
||||||
}
|
}
|
||||||
return QE_OK;
|
return QE_OK;
|
||||||
@@ -1724,7 +1734,7 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
|
|||||||
|
|
||||||
void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int *indices,unsigned indexcount)
|
void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, btVector3* overts,unsigned int &ocount,unsigned int *indices,unsigned indexcount)
|
||||||
{
|
{
|
||||||
unsigned int *used = (unsigned int *)btAlignedAlloc(sizeof(unsigned int)*vcount,16);
|
unsigned int *used = new unsigned int[vcount];
|
||||||
memset(used,0,sizeof(unsigned int)*vcount);
|
memset(used,0,sizeof(unsigned int)*vcount);
|
||||||
|
|
||||||
ocount = 0;
|
ocount = 0;
|
||||||
@@ -1756,5 +1766,5 @@ void HullLibrary::BringOutYourDead(const btVector3* verts,unsigned int vcount, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btAlignedFree(used);
|
delete[] used;
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "btShapeHull.h"
|
#include "btShapeHull.h"
|
||||||
#include "LinearMath/btConvexHull.h"
|
#include "btConvexHull.h"
|
||||||
|
|
||||||
#define NUM_UNITSPHERE_POINTS 42
|
#define NUM_UNITSPHERE_POINTS 42
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
|||||||
#define _SHAPE_HULL_H
|
#define _SHAPE_HULL_H
|
||||||
|
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
#include "btConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||||
|
|
||||||
|
|
||||||
///btShapeHull takes a btConvexShape, builds the convex hull using btConvexHull and provides triangle indices and vertices.
|
///btShapeHull takes a btConvexShape, builds the convex hull using btConvexHull and provides triangle indices and vertices.
|
||||||
@@ -3,6 +3,7 @@ SubDir TOP Extras ;
|
|||||||
SubInclude TOP Extras ConvexDecomposition ;
|
SubInclude TOP Extras ConvexDecomposition ;
|
||||||
SubInclude TOP Extras COLLADA_DOM ;
|
SubInclude TOP Extras COLLADA_DOM ;
|
||||||
SubInclude TOP Extras glui ;
|
SubInclude TOP Extras glui ;
|
||||||
|
SubInclude TOP Extras ConvexHull ;
|
||||||
SubInclude TOP Extras LibXML ;
|
SubInclude TOP Extras LibXML ;
|
||||||
SubInclude TOP Extras BulletColladaConverter ;
|
SubInclude TOP Extras BulletColladaConverter ;
|
||||||
SubInclude TOP Extras BulletMultiThreaded ;
|
SubInclude TOP Extras BulletMultiThreaded ;
|
||||||
|
|||||||
@@ -182,20 +182,16 @@ void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void btHeightfieldTerrainShape::quantizeWithClamp(int* out, const btVector3& point) const
|
void btHeightfieldTerrainShape::quantizeWithClamp(int* out, const btVector3& point,int isMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
btVector3 clampedPoint(point);
|
btVector3 clampedPoint(point);
|
||||||
clampedPoint.setMax(m_localAabbMin);
|
clampedPoint.setMax(m_localAabbMin);
|
||||||
clampedPoint.setMin(m_localAabbMax);
|
clampedPoint.setMin(m_localAabbMax);
|
||||||
|
|
||||||
btVector3 v = (clampedPoint );// * m_quantization;
|
btVector3 v = (clampedPoint);// - m_bvhAabbMin) * m_bvhQuantization;
|
||||||
|
out[0] = (unsigned short)(((unsigned short)v.getX() & 0xffffffe) | isMax);
|
||||||
// SMJ - Add 0.5 in the correct direction before doing the int conversion.
|
out[1] = (unsigned short)(((unsigned short)v.getY() & 0xffffffe) | isMax);
|
||||||
out[0] = (int)(v.getX() + v.getX() / btFabs(v.getX())* btScalar(0.5) );
|
out[2] = (unsigned short)(((unsigned short)v.getZ() & 0xffffffe) | isMax);
|
||||||
out[1] = (int)(v.getY() + v.getY() / btFabs(v.getY())* btScalar(0.5) );
|
|
||||||
out[2] = (int)(v.getZ() + v.getZ() / btFabs(v.getZ())* btScalar(0.5) );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,8 +210,8 @@ void btHeightfieldTerrainShape::processAllTriangles(btTriangleCallback* callback
|
|||||||
btVector3 localAabbMin = aabbMin*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
|
btVector3 localAabbMin = aabbMin*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
|
||||||
btVector3 localAabbMax = aabbMax*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
|
btVector3 localAabbMax = aabbMax*btVector3(1.f/m_localScaling[0],1.f/m_localScaling[1],1.f/m_localScaling[2]);
|
||||||
|
|
||||||
quantizeWithClamp(quantizedAabbMin, localAabbMin);
|
quantizeWithClamp(quantizedAabbMin, localAabbMin,0);
|
||||||
quantizeWithClamp(quantizedAabbMax, localAabbMax);
|
quantizeWithClamp(quantizedAabbMax, localAabbMax,1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ protected:
|
|||||||
btVector3 m_localScaling;
|
btVector3 m_localScaling;
|
||||||
|
|
||||||
virtual btScalar getHeightFieldValue(int x,int y) const;
|
virtual btScalar getHeightFieldValue(int x,int y) const;
|
||||||
void quantizeWithClamp(int* out, const btVector3& point) const;
|
void quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
|
||||||
void getVertex(int x,int y,btVector3& vertex) const;
|
void getVertex(int x,int y,btVector3& vertex) const;
|
||||||
|
|
||||||
inline bool testQuantizedAabbAgainstQuantizedAabb(int* aabbMin1, int* aabbMax1,const int* aabbMin2,const int* aabbMax2) const
|
inline bool testQuantizedAabbAgainstQuantizedAabb(int* aabbMin1, int* aabbMax1,const int* aabbMin2,const int* aabbMax2) const
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ void btOptimizedBvh::build(btStridingMeshInterface* triangles, bool useQuantized
|
|||||||
aabbMin.setZ(aabbMin.z() - MIN_AABB_HALF_DIMENSION);
|
aabbMin.setZ(aabbMin.z() - MIN_AABB_HALF_DIMENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_optimizedTree->quantizeWithClamp(&node.m_quantizedAabbMin[0],aabbMin);
|
m_optimizedTree->quantizeWithClamp(&node.m_quantizedAabbMin[0],aabbMin,0);
|
||||||
m_optimizedTree->quantizeWithClamp(&node.m_quantizedAabbMax[0],aabbMax);
|
m_optimizedTree->quantizeWithClamp(&node.m_quantizedAabbMax[0],aabbMax,1);
|
||||||
|
|
||||||
node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
|
node.m_escapeIndexOrTriangleIndex = (partId<<(31-MAX_NUM_PARTS_IN_BITS)) | triangleIndex;
|
||||||
|
|
||||||
@@ -221,8 +221,8 @@ void btOptimizedBvh::refitPartial(btStridingMeshInterface* meshInterface,const b
|
|||||||
unsigned short quantizedQueryAabbMin[3];
|
unsigned short quantizedQueryAabbMin[3];
|
||||||
unsigned short quantizedQueryAabbMax[3];
|
unsigned short quantizedQueryAabbMax[3];
|
||||||
|
|
||||||
quantizeWithClamp(&quantizedQueryAabbMin[0],aabbMin);
|
quantizeWithClamp(&quantizedQueryAabbMin[0],aabbMin,0);
|
||||||
quantizeWithClamp(&quantizedQueryAabbMax[0],aabbMax);
|
quantizeWithClamp(&quantizedQueryAabbMax[0],aabbMax,1);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<this->m_SubtreeHeaders.size();i++)
|
for (i=0;i<this->m_SubtreeHeaders.size();i++)
|
||||||
@@ -328,8 +328,8 @@ void btOptimizedBvh::updateBvhNodes(btStridingMeshInterface* meshInterface,int f
|
|||||||
aabbMin.setMin(triangleVerts[2]);
|
aabbMin.setMin(triangleVerts[2]);
|
||||||
aabbMax.setMax(triangleVerts[2]);
|
aabbMax.setMax(triangleVerts[2]);
|
||||||
|
|
||||||
quantizeWithClamp(&curNode.m_quantizedAabbMin[0],aabbMin);
|
quantizeWithClamp(&curNode.m_quantizedAabbMin[0],aabbMin,0);
|
||||||
quantizeWithClamp(&curNode.m_quantizedAabbMax[0],aabbMax);
|
quantizeWithClamp(&curNode.m_quantizedAabbMax[0],aabbMax,1);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -613,8 +613,8 @@ void btOptimizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
|
|||||||
///quantize query AABB
|
///quantize query AABB
|
||||||
unsigned short int quantizedQueryAabbMin[3];
|
unsigned short int quantizedQueryAabbMin[3];
|
||||||
unsigned short int quantizedQueryAabbMax[3];
|
unsigned short int quantizedQueryAabbMax[3];
|
||||||
quantizeWithClamp(quantizedQueryAabbMin,aabbMin);
|
quantizeWithClamp(quantizedQueryAabbMin,aabbMin,0);
|
||||||
quantizeWithClamp(quantizedQueryAabbMax,aabbMax);
|
quantizeWithClamp(quantizedQueryAabbMax,aabbMax,1);
|
||||||
|
|
||||||
switch (m_traversalMode)
|
switch (m_traversalMode)
|
||||||
{
|
{
|
||||||
@@ -783,8 +783,8 @@ void btOptimizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
|||||||
|
|
||||||
unsigned short int quantizedQueryAabbMin[3];
|
unsigned short int quantizedQueryAabbMin[3];
|
||||||
unsigned short int quantizedQueryAabbMax[3];
|
unsigned short int quantizedQueryAabbMax[3];
|
||||||
quantizeWithClamp(quantizedQueryAabbMin,rayAabbMin);
|
quantizeWithClamp(quantizedQueryAabbMin,rayAabbMin,0);
|
||||||
quantizeWithClamp(quantizedQueryAabbMax,rayAabbMax);
|
quantizeWithClamp(quantizedQueryAabbMax,rayAabbMax,1);
|
||||||
|
|
||||||
while (curIndex < endNodeIndex)
|
while (curIndex < endNodeIndex)
|
||||||
{
|
{
|
||||||
@@ -833,11 +833,11 @@ void btOptimizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback*
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef RAYAABB2
|
#ifdef RAYAABB2
|
||||||
///disable this check: need to check division by zero (above) and fix the unQuantize method
|
///careful with this check: need to check division by zero (above) and fix the unQuantize method
|
||||||
///thanks Joerg/hiker for the reproduction case!
|
///thanks Joerg/hiker for the reproduction case!
|
||||||
///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
|
///http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=1858
|
||||||
|
|
||||||
rayBoxOverlap = true;//btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0, lambda_max);
|
rayBoxOverlap = btRayAabb2 (raySource, rayDirection, sign, bounds, param, 0.0f, lambda_max);
|
||||||
#else
|
#else
|
||||||
rayBoxOverlap = true;//btRayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
|
rayBoxOverlap = true;//btRayAabb(raySource, rayTarget, bounds[0], bounds[1], param, normal);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ protected:
|
|||||||
{
|
{
|
||||||
if (m_useQuantization)
|
if (m_useQuantization)
|
||||||
{
|
{
|
||||||
quantizeWithClamp(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] ,aabbMin);
|
quantizeWithClamp(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[0] ,aabbMin,0);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
m_contiguousNodes[nodeIndex].m_aabbMinOrg = aabbMin;
|
m_contiguousNodes[nodeIndex].m_aabbMinOrg = aabbMin;
|
||||||
@@ -202,7 +202,7 @@ protected:
|
|||||||
{
|
{
|
||||||
if (m_useQuantization)
|
if (m_useQuantization)
|
||||||
{
|
{
|
||||||
quantizeWithClamp(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0],aabbMax);
|
quantizeWithClamp(&m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMax[0],aabbMax,1);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
m_contiguousNodes[nodeIndex].m_aabbMaxOrg = aabbMax;
|
m_contiguousNodes[nodeIndex].m_aabbMaxOrg = aabbMax;
|
||||||
@@ -251,8 +251,8 @@ protected:
|
|||||||
{
|
{
|
||||||
unsigned short int quantizedAabbMin[3];
|
unsigned short int quantizedAabbMin[3];
|
||||||
unsigned short int quantizedAabbMax[3];
|
unsigned short int quantizedAabbMax[3];
|
||||||
quantizeWithClamp(quantizedAabbMin,newAabbMin);
|
quantizeWithClamp(quantizedAabbMin,newAabbMin,0);
|
||||||
quantizeWithClamp(quantizedAabbMax,newAabbMax);
|
quantizeWithClamp(quantizedAabbMax,newAabbMax,1);
|
||||||
for (int i=0;i<3;i++)
|
for (int i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] > quantizedAabbMin[i])
|
if (m_quantizedContiguousNodes[nodeIndex].m_quantizedAabbMin[i] > quantizedAabbMin[i])
|
||||||
@@ -333,7 +333,7 @@ public:
|
|||||||
void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
|
void reportRayOverlappingNodex (btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget) const;
|
||||||
void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const;
|
void reportBoxCastOverlappingNodex(btNodeOverlapCallback* nodeCallback, const btVector3& raySource, const btVector3& rayTarget, const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||||
|
|
||||||
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point) const
|
SIMD_FORCE_INLINE void quantizeWithClamp(unsigned short* out, const btVector3& point,int isMax) const
|
||||||
{
|
{
|
||||||
|
|
||||||
btAssert(m_useQuantization);
|
btAssert(m_useQuantization);
|
||||||
@@ -341,14 +341,12 @@ public:
|
|||||||
btVector3 clampedPoint(point);
|
btVector3 clampedPoint(point);
|
||||||
clampedPoint.setMax(m_bvhAabbMin);
|
clampedPoint.setMax(m_bvhAabbMin);
|
||||||
clampedPoint.setMin(m_bvhAabbMax);
|
clampedPoint.setMin(m_bvhAabbMax);
|
||||||
|
|
||||||
btVector3 v = (clampedPoint - m_bvhAabbMin) * m_bvhQuantization;
|
btVector3 v = (clampedPoint - m_bvhAabbMin) * m_bvhQuantization;
|
||||||
out[0] = (unsigned short)(v.getX()+0.5f);
|
out[0] = (unsigned short)(((unsigned short)v.getX() & 0xfffe) | isMax);
|
||||||
out[1] = (unsigned short)(v.getY()+0.5f);
|
out[1] = (unsigned short)(((unsigned short)v.getY() & 0xfffe) | isMax);
|
||||||
out[2] = (unsigned short)(v.getZ()+0.5f);
|
out[2] = (unsigned short)(((unsigned short)v.getZ() & 0xfffe) | isMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const
|
SIMD_FORCE_INLINE btVector3 unQuantize(const unsigned short* vecIn) const
|
||||||
{
|
{
|
||||||
btVector3 vecOut;
|
btVector3 vecOut;
|
||||||
|
|||||||
Reference in New Issue
Block a user