fix BT_USE_DOUBLE_PRECISION build, address Issue 177
https://github.com/bulletphysics/bullet3/issues/177
This commit is contained in:
@@ -26,8 +26,8 @@ BasicDemo::~BasicDemo()
|
|||||||
void BasicDemo::createGround(int cubeShapeId)
|
void BasicDemo::createGround(int cubeShapeId)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
float color[]={0.3,0.3,1,1};
|
btVector4 color(0.3,0.3,1,1);
|
||||||
float halfExtents[]={50,50,50,1};
|
btVector4 halfExtents(50,50,50,1);
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-50,0));
|
groundTransform.setOrigin(btVector3(0,-50,0));
|
||||||
@@ -71,7 +71,7 @@ void BasicDemo::initPhysics()
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
float halfExtents[]={scaling,scaling,scaling,1};
|
btVector4 halfExtents(scaling,scaling,scaling,1);
|
||||||
btVector4 colors[4] =
|
btVector4 colors[4] =
|
||||||
{
|
{
|
||||||
btVector4(1,0,0,1),
|
btVector4(1,0,0,1),
|
||||||
|
|||||||
@@ -15,8 +15,11 @@ public:
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
|
virtual void drawLine(const btVector3& from1,const btVector3& to1,const btVector3& color1)
|
||||||
{
|
{
|
||||||
|
float from[4] = {from1[0],from1[1],from1[2],from1[3]};
|
||||||
|
float to[4] = {to1[0],to1[1],to1[2],to1[3]};
|
||||||
|
float color[4] = {color1[0],color1[1],color1[2],color1[3]};
|
||||||
m_glApp->m_instancingRenderer->drawLine(from,to,color);
|
m_glApp->m_instancingRenderer->drawLine(from,to,color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ ChainDemo::~ChainDemo()
|
|||||||
void ChainDemo::createGround(int cubeShapeId)
|
void ChainDemo::createGround(int cubeShapeId)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
float color[]={0.3,0.3,1,1};
|
btVector4 color(0.3,0.3,1,1);
|
||||||
float halfExtents[]={50,1,50,1};
|
btVector4 halfExtents(50,1,50,1);
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-5,0));
|
groundTransform.setOrigin(btVector3(0,-5,0));
|
||||||
@@ -85,7 +85,7 @@ void ChainDemo::initPhysics()
|
|||||||
int sphereShapeId = m_glApp->registerGraphicsSphereShape(radius,false);
|
int sphereShapeId = m_glApp->registerGraphicsSphereShape(radius,false);
|
||||||
|
|
||||||
{
|
{
|
||||||
float halfExtents[]={scaling,scaling,scaling,1};
|
btVector4 halfExtents(scaling,scaling,scaling,1);
|
||||||
btVector4 colors[4] =
|
btVector4 colors[4] =
|
||||||
{
|
{
|
||||||
btVector4(1,0,0,1),
|
btVector4(1,0,0,1),
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ struct GraphicsVertex
|
|||||||
float texcoord[2];
|
float texcoord[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
static b3Vector4 colors[4] =
|
static btVector4 colors[4] =
|
||||||
{
|
{
|
||||||
b3MakeVector4(1,0,0,1),
|
btVector4(1,0,0,1),
|
||||||
b3MakeVector4(0,1,0,1),
|
btVector4(0,1,0,1),
|
||||||
b3MakeVector4(0,1,1,1),
|
btVector4(0,1,1,1),
|
||||||
b3MakeVector4(1,1,0,1),
|
btVector4(1,1,0,1),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -435,7 +435,7 @@ btMultiBody* FeatherstoneDemo1::createFeatherstoneMultiBody(class btMultiBodyDyn
|
|||||||
world_to_local[0] = bod->getWorldToBaseRot();
|
world_to_local[0] = bod->getWorldToBaseRot();
|
||||||
local_origin[0] = bod->getBasePos();
|
local_origin[0] = bod->getBasePos();
|
||||||
//float halfExtents[3]={7.5,0.05,4.5};
|
//float halfExtents[3]={7.5,0.05,4.5};
|
||||||
float halfExtents[3]={7.5,0.45,4.5};
|
btVector4 halfExtents(7.5,0.45,4.5,1);
|
||||||
{
|
{
|
||||||
|
|
||||||
float pos[4]={local_origin[0].x(),local_origin[0].y(),local_origin[0].z(),1};
|
float pos[4]={local_origin[0].x(),local_origin[0].y(),local_origin[0].z(),1};
|
||||||
@@ -455,7 +455,7 @@ btMultiBody* FeatherstoneDemo1::createFeatherstoneMultiBody(class btMultiBodyDyn
|
|||||||
tr.setRotation(btQuaternion(quat[0],quat[1],quat[2],quat[3]));
|
tr.setRotation(btQuaternion(quat[0],quat[1],quat[2],quat[3]));
|
||||||
col->setWorldTransform(tr);
|
col->setWorldTransform(tr);
|
||||||
|
|
||||||
b3Vector4 color = colors[curColor++];
|
btVector4 color = colors[curColor++];
|
||||||
curColor&=3;
|
curColor&=3;
|
||||||
|
|
||||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
||||||
@@ -500,7 +500,7 @@ btMultiBody* FeatherstoneDemo1::createFeatherstoneMultiBody(class btMultiBodyDyn
|
|||||||
col->setFriction(friction);
|
col->setFriction(friction);
|
||||||
|
|
||||||
|
|
||||||
b3Vector4 color = colors[curColor++];
|
btVector4 color = colors[curColor++];
|
||||||
curColor&=3;
|
curColor&=3;
|
||||||
|
|
||||||
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
int index = m_glApp->m_instancingRenderer->registerGraphicsInstance(cubeShapeId,tr.getOrigin(),tr.getRotation(),color,halfExtents);
|
||||||
@@ -536,8 +536,8 @@ void FeatherstoneDemo1::createGround()
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
float color[]={0.3,0.3,1,1};
|
btVector4 color(0.3,0.3,1,1);
|
||||||
float halfExtents[]={50,50,50,1};
|
btVector4 halfExtents(50,50,50,1);
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-50,0));
|
groundTransform.setOrigin(btVector3(0,-50,0));
|
||||||
|
|||||||
@@ -582,6 +582,15 @@ void GLInstancingRenderer::writeTransforms()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const double* pos1, const double* orn1, const double* color1, const double* scaling1)
|
||||||
|
{
|
||||||
|
float pos[4] = {pos1[0],pos1[1],pos1[2],pos1[3]};
|
||||||
|
float orn[4] = {orn1[0],orn1[1],orn1[2],orn1[3]};
|
||||||
|
float color[4] = {color1[0],color1[1],color1[2],color1[3]};
|
||||||
|
float scaling[4] = {scaling1[0],scaling1[1],scaling1[2],scaling1[3]};
|
||||||
|
return registerGraphicsInstance(shapeIndex,pos,orn,color,scaling);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
|
int GLInstancingRenderer::registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -77,10 +77,26 @@ public:
|
|||||||
|
|
||||||
///position x,y,z, quaternion x,y,z,w, color r,g,b,a, scaling x,y,z
|
///position x,y,z, quaternion x,y,z,w, color r,g,b,a, scaling x,y,z
|
||||||
int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
|
int registerGraphicsInstance(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
|
||||||
|
int registerGraphicsInstance(int shapeIndex, const double* position, const double* quaternion, const double* color, const double* scaling);
|
||||||
|
|
||||||
void writeTransforms();
|
void writeTransforms();
|
||||||
|
|
||||||
void writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex);
|
void writeSingleInstanceTransformToCPU(const float* position, const float* orientation, int srcIndex);
|
||||||
|
void writeSingleInstanceTransformToCPU(const double* position, const double* orientation, int srcIndex)
|
||||||
|
{
|
||||||
|
float pos[4];
|
||||||
|
float orn[4];
|
||||||
|
pos[0] = position[0];
|
||||||
|
pos[1] = position[1];
|
||||||
|
pos[2] = position[2];
|
||||||
|
pos[3] = position[3];
|
||||||
|
orn[0] =orientation[0];
|
||||||
|
orn[1] =orientation[1];
|
||||||
|
orn[2] =orientation[2];
|
||||||
|
orn[3] =orientation[3];
|
||||||
|
writeSingleInstanceTransformToCPU(pos,orn,srcIndex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void writeSingleInstanceTransformToGPU(float* position, float* orientation, int srcIndex);
|
void writeSingleInstanceTransformToGPU(float* position, float* orientation, int srcIndex);
|
||||||
|
|
||||||
@@ -97,12 +113,32 @@ public:
|
|||||||
void updateCamera();
|
void updateCamera();
|
||||||
|
|
||||||
void getCameraPosition(float cameraPos[4]);
|
void getCameraPosition(float cameraPos[4]);
|
||||||
|
void getCameraPosition(double cameraPos[4])
|
||||||
|
{
|
||||||
|
float campos[4];
|
||||||
|
getCameraPosition(campos);
|
||||||
|
cameraPos[0] = campos[0];
|
||||||
|
cameraPos[1] = campos[1];
|
||||||
|
cameraPos[2] = campos[2];
|
||||||
|
cameraPos[3] = campos[3];
|
||||||
|
}
|
||||||
|
|
||||||
void setCameraDistance(float dist);
|
void setCameraDistance(float dist);
|
||||||
float getCameraDistance() const;
|
float getCameraDistance() const;
|
||||||
|
|
||||||
//set the camera 'target'
|
//set the camera 'target'
|
||||||
void setCameraTargetPosition(float cameraPos[4]);
|
void setCameraTargetPosition(float cameraPos[4]);
|
||||||
void getCameraTargetPosition(float cameraPos[4]) const;
|
void getCameraTargetPosition(float cameraPos[4]) const;
|
||||||
|
void getCameraTargetPosition(double cameraPos[4]) const
|
||||||
|
{
|
||||||
|
float campos[4];
|
||||||
|
getCameraTargetPosition(campos);
|
||||||
|
cameraPos[0] = campos[0];
|
||||||
|
cameraPos[1] = campos[1];
|
||||||
|
cameraPos[2] = campos[2];
|
||||||
|
cameraPos[3] = campos[3];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void setCameraYaw(float yaw);
|
void setCameraYaw(float yaw);
|
||||||
void setCameraPitch(float pitch);
|
void setCameraPitch(float pitch);
|
||||||
|
|||||||
Reference in New Issue
Block a user