fixes in serialization (don't serialize shapes multiple times), hull shape issue,
fix InternalEdgeDemo compilation using GLUT
This commit is contained in:
@@ -190,7 +190,7 @@ void InternalEdgeDemo::initPhysics()
|
||||
|
||||
//gVertices[1].setY(21.1);
|
||||
//gVertices[1].setY(121.1);
|
||||
gVertices[1].setY(.1);
|
||||
gVertices[1].setY(.1f);
|
||||
|
||||
#ifdef ROTATE_GROUND
|
||||
//gVertices[1].setY(-1.1);
|
||||
@@ -353,7 +353,7 @@ void InternalEdgeDemo::initPhysics()
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||
m_dynamicsWorld->getSolverInfo().m_splitImpulse = true;
|
||||
m_dynamicsWorld->getSolverInfo().m_splitImpulsePenetrationThreshold = 1e30f;
|
||||
m_dynamicsWorld->getSolverInfo().m_maxErrorReduction = 1e30;
|
||||
m_dynamicsWorld->getSolverInfo().m_maxErrorReduction = 1e30f;
|
||||
m_dynamicsWorld->getSolverInfo().m_erp =1.f;
|
||||
m_dynamicsWorld->getSolverInfo().m_erp2 = 1.f;
|
||||
|
||||
@@ -375,7 +375,7 @@ void InternalEdgeDemo::initPhysics()
|
||||
{
|
||||
for (int i=0;i<1;i++)
|
||||
{
|
||||
startTransform.setOrigin(btVector3(-10+i*3,1+i*0.1,-1.3));
|
||||
startTransform.setOrigin(btVector3(-10.f+i*3.f,1.f+btScalar(i)*0.1f,-1.3f));
|
||||
btRigidBody* body = localCreateRigidBody(100, startTransform,colShape);
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
body->setLinearVelocity(btVector3(0,0,-1));
|
||||
@@ -485,7 +485,7 @@ void InternalEdgeDemo::clientMoveAndDisplay()
|
||||
renderme();
|
||||
|
||||
glFlush();
|
||||
glutSwapBuffers();
|
||||
swapBuffers();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,14 @@ subject to the following restrictions:
|
||||
#ifndef CONCAVE_DEMO_H
|
||||
#define CONCAVE_DEMO_H
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include "Win32DemoApplication.h"
|
||||
#define PlatformDemoApplication Win32DemoApplication
|
||||
#else
|
||||
#include "GlutDemoApplication.h"
|
||||
#define PlatformDemoApplication GlutDemoApplication
|
||||
#endif
|
||||
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
class btBroadphaseInterface;
|
||||
@@ -29,7 +36,7 @@ class btTriangleIndexVertexArray;
|
||||
|
||||
///InternalEdgeDemo shows usage of static concave triangle meshes
|
||||
///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
|
||||
class InternalEdgeDemo : public GlutDemoApplication
|
||||
class InternalEdgeDemo : public PlatformDemoApplication
|
||||
{
|
||||
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
|
||||
@@ -19,7 +19,7 @@ subject to the following restrictions:
|
||||
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
|
||||
DemoApplication* createDemo()
|
||||
{
|
||||
return new InternalEdgeDemo.cpp();
|
||||
return new InternalEdgeDemo();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -161,9 +161,9 @@ void SerializeDemo::initPhysics()
|
||||
btVector3 positions[2] = {btVector3(0.1f,0.2f,0.3f),btVector3(0.4f,0.5f,0.6f)};
|
||||
btScalar radii[2] = {0.3f,0.4f};
|
||||
|
||||
//btMultiSphereShape* colShape = new btMultiSphereShape(positions,radii,numSpheres);
|
||||
btMultiSphereShape* colShape = new btMultiSphereShape(positions,radii,numSpheres);
|
||||
|
||||
btCollisionShape* colShape = new btCapsuleShapeZ(SCALING*1,SCALING*1);
|
||||
//btCollisionShape* colShape = new btCapsuleShapeZ(SCALING*1,SCALING*1);
|
||||
//btCollisionShape* colShape = new btCylinderShapeZ(btVector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
//btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||
|
||||
@@ -253,6 +253,7 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
|
||||
{
|
||||
hullShape->addPoint(tmpPoints[i]);
|
||||
}
|
||||
shape = hullShape;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -305,12 +305,13 @@ const char* btCompoundShape::serialize(void* dataBuffer, btSerializer* serialize
|
||||
{
|
||||
memPtr->m_childMargin = float(m_children[i].m_childMargin);
|
||||
memPtr->m_childShape = (btCollisionShapeData*)m_children[i].m_childShape;
|
||||
|
||||
//don't serialize shapes that already have been serialized
|
||||
if (!serializer->findPointer(memPtr->m_childShape))
|
||||
{
|
||||
btChunk* chunk = serializer->allocate(m_children[i].m_childShape->calculateSerializeBufferSize(),1);
|
||||
const char* structType = m_children[i].m_childShape->serialize(chunk->m_oldPtr,serializer);
|
||||
serializer->finalizeChunk(chunk,structType,BT_SHAPE_CODE,m_children[i].m_childShape);
|
||||
}
|
||||
}
|
||||
|
||||
memPtr->m_childShapeType = m_children[i].m_childShapeType;
|
||||
m_children[i].m_transform.serializeFloat(memPtr->m_transform);
|
||||
|
||||
@@ -53,7 +53,9 @@ public:
|
||||
|
||||
virtual btChunk* allocate(size_t size, int numElements) = 0;
|
||||
|
||||
virtual void finalizeChunk(btChunk* chunk, const char* structType, int chunkCode,void* oldPtr) const = 0;
|
||||
virtual void finalizeChunk(btChunk* chunk, const char* structType, int chunkCode,void* oldPtr)= 0;
|
||||
|
||||
virtual void* findPointer(void* oldPtr) = 0;
|
||||
|
||||
virtual void startSerialization() = 0;
|
||||
|
||||
@@ -89,14 +91,27 @@ class btDefaultSerializer : public btSerializer
|
||||
btHashMap<btHashInt, int> mStructReverse;
|
||||
btHashMap<btHashString,int> mTypeLookup;
|
||||
|
||||
btAlignedObjectArray<btChunk*> m_chunkPtrs;
|
||||
|
||||
btHashMap<btHashPtr,void*> m_chunkP;
|
||||
|
||||
int m_totalSize;
|
||||
unsigned char* m_buffer;
|
||||
int m_currentSize;
|
||||
|
||||
btAlignedObjectArray<btChunk*> m_chunkPtrs;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void* findPointer(void* oldPtr)
|
||||
{
|
||||
void** ptr = m_chunkP.find(oldPtr);
|
||||
if (ptr && *ptr)
|
||||
return *ptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void writeDNA()
|
||||
{
|
||||
unsigned char* dnaTarget = m_buffer+m_currentSize;
|
||||
@@ -389,12 +404,16 @@ public:
|
||||
return m_currentSize;
|
||||
}
|
||||
|
||||
virtual void finalizeChunk(btChunk* chunk, const char* structType, int chunkCode,void* oldPtr) const
|
||||
virtual void finalizeChunk(btChunk* chunk, const char* structType, int chunkCode,void* oldPtr)
|
||||
{
|
||||
btAssert(!findPointer(oldPtr));
|
||||
|
||||
chunk->m_dna_nr = getReverseType(structType);
|
||||
|
||||
chunk->m_chunkCode = chunkCode;
|
||||
m_chunkP.insert(oldPtr,chunk->m_oldPtr);
|
||||
chunk->m_oldPtr = oldPtr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -406,6 +425,7 @@ public:
|
||||
|
||||
unsigned char* ptr = m_buffer+m_currentSize;
|
||||
m_currentSize += int(size)*numElements+sizeof(btChunk);
|
||||
btAssert(m_currentSize<m_totalSize);
|
||||
|
||||
unsigned char* data = ptr + sizeof(btChunk);
|
||||
|
||||
@@ -416,6 +436,7 @@ public:
|
||||
chunk->m_number = numElements;
|
||||
|
||||
m_chunkPtrs.push_back(chunk);
|
||||
|
||||
|
||||
return chunk;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user