fix shadowmap crash on some Intel GPUs, see https://github.com/bulletphysics/bullet3/issues/4
remove targetdir from all libraries in premake, so it is much easier to create a separate folder for all binary+lib transmit the serialized btMultiBody data back from server to client, after the server loads a URDF file. This includes base+link+joint names tweak the serialization routines, so it is easier to skip pointers and to serialize directly to a shared memory buffer also tweak the serialization code to allow to process data without 'DNA' schema data (assuming file-DNA = memory DNA)
This commit is contained in:
@@ -1325,7 +1325,33 @@ void GLInstancingRenderer::renderSceneInternal(int renderMode)
|
||||
glBindTexture(GL_TEXTURE_2D,m_data->m_shadowTexture);
|
||||
//glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT16,m_screenWidth,m_screenHeight,0,GL_DEPTH_COMPONENT,GL_FLOAT,0);
|
||||
//glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT32,m_screenWidth,m_screenHeight,0,GL_DEPTH_COMPONENT,GL_FLOAT,0);
|
||||
|
||||
#ifdef OLD_SHADOWMAP_INIT
|
||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT16, shadowMapWidth, shadowMapHeight, 0,GL_DEPTH_COMPONENT, GL_FLOAT, 0);
|
||||
#else//OLD_SHADOWMAP_INIT
|
||||
//Reduce size of shadowMap if glTexImage2D call fails as may happen in some cases
|
||||
//https://github.com/bulletphysics/bullet3/issues/40
|
||||
|
||||
int size;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
|
||||
if (size < shadowMapWidth){
|
||||
shadowMapWidth = size;
|
||||
}
|
||||
if (size < shadowMapHeight){
|
||||
shadowMapHeight = size;
|
||||
}
|
||||
GLuint err;
|
||||
do {
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16,
|
||||
shadowMapWidth, shadowMapHeight,
|
||||
0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
|
||||
err = glGetError();
|
||||
if (err!=GL_NO_ERROR){
|
||||
shadowMapHeight >>= 1;
|
||||
shadowMapWidth >>= 1;
|
||||
}
|
||||
} while (err != GL_NO_ERROR && shadowMapWidth > 0);
|
||||
#endif//OLD_SHADOWMAP_INIT
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "SharedMemoryCommon.h"
|
||||
#include "../CommonInterfaces/CommonParameterInterface.h"
|
||||
#include "../Utils/b3ResourcePath.h"
|
||||
#include "../Extras/Serialize/BulletFileLoader/btBulletFile.h"
|
||||
|
||||
class PhysicsClient : public SharedMemoryCommon
|
||||
{
|
||||
@@ -181,6 +182,57 @@ void PhysicsClient::processServerCommands()
|
||||
{
|
||||
m_serverLoadUrdfOK = true;
|
||||
b3Printf("Server loading the URDF OK\n");
|
||||
|
||||
if (serverCmd.m_dataStreamArguments.m_streamChunkLength>0)
|
||||
{
|
||||
bParse::btBulletFile* bf = new bParse::btBulletFile(this->m_testBlock1->m_bulletStreamDataServerToClient,serverCmd.m_dataStreamArguments.m_streamChunkLength);
|
||||
bf->setFileDNAisMemoryDNA();
|
||||
bf->parse(false);
|
||||
for (int i=0;i<bf->m_multiBodies.size();i++)
|
||||
{
|
||||
int flag = bf->getFlags();
|
||||
|
||||
if ((flag&bParse::FD_DOUBLE_PRECISION)!=0)
|
||||
{
|
||||
btMultiBodyDoubleData* mb = (btMultiBodyDoubleData*)bf->m_multiBodies[i];
|
||||
if (mb->m_baseName)
|
||||
{
|
||||
b3Printf("mb->m_baseName = %s\n",mb->m_baseName);
|
||||
}
|
||||
for (int link=0;link<mb->m_numLinks;link++)
|
||||
{
|
||||
if (mb->m_links[link].m_linkName)
|
||||
{
|
||||
b3Printf("mb->m_links[%d].m_linkName = %s\n",link,mb->m_links[link].m_linkName);
|
||||
}
|
||||
if (mb->m_links[link].m_jointName)
|
||||
{
|
||||
b3Printf("mb->m_links[%d].m_jointName = %s\n",link,mb->m_links[link].m_jointName);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
btMultiBodyFloatData* mb = (btMultiBodyFloatData*) bf->m_multiBodies[i];
|
||||
if (mb->m_baseName)
|
||||
{
|
||||
b3Printf("mb->m_baseName = %s\n",mb->m_baseName);
|
||||
}
|
||||
for (int link=0;link<mb->m_numLinks;link++)
|
||||
{
|
||||
if (mb->m_links[link].m_linkName)
|
||||
{
|
||||
b3Printf("mb->m_links[%d].m_linkName = %s\n",link,mb->m_links[link].m_linkName);
|
||||
}
|
||||
b3Printf("link [%d] type = %d",link, mb->m_links[link].m_jointType);
|
||||
if (mb->m_links[link].m_jointName)
|
||||
{
|
||||
b3Printf("mb->m_links[%d].m_jointName = %s\n",link,mb->m_links[link].m_jointName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("ok!\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMD_STEP_FORWARD_SIMULATION_COMPLETED:
|
||||
@@ -196,10 +248,17 @@ void PhysicsClient::processServerCommands()
|
||||
|
||||
case CMD_BULLET_DATA_STREAM_RECEIVED_COMPLETED:
|
||||
{
|
||||
b3Printf("Server received bullet data stream OK\n");
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_BULLET_DATA_STREAM_RECEIVED_FAILED:
|
||||
{
|
||||
b3Printf("Server failed receiving bullet data stream\n");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
|
||||
|
||||
#include "PhysicsServer.h"
|
||||
|
||||
#include "PosixSharedMemory.h"
|
||||
@@ -10,7 +12,16 @@
|
||||
#include "../Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h"
|
||||
|
||||
#include "SharedMemoryCommon.h"
|
||||
const char* blaatnaam = "basename";
|
||||
struct UrdfLinkNameMapUtil
|
||||
{
|
||||
btMultiBody* m_mb;
|
||||
btDefaultSerializer* m_memSerializer;
|
||||
|
||||
UrdfLinkNameMapUtil():m_mb(0),m_memSerializer(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class PhysicsServer : public SharedMemoryCommon
|
||||
{
|
||||
@@ -19,7 +30,8 @@ class PhysicsServer : public SharedMemoryCommon
|
||||
|
||||
btAlignedObjectArray<btJointFeedback*> m_jointFeedbacks;
|
||||
btAlignedObjectArray<btBulletWorldImporter*> m_worldImporters;
|
||||
|
||||
btAlignedObjectArray<UrdfLinkNameMapUtil*> m_urdfLinkNameMapper;
|
||||
btAlignedObjectArray<std::string*> m_strings;
|
||||
bool m_wantsShutdown;
|
||||
|
||||
public:
|
||||
@@ -155,6 +167,44 @@ bool PhysicsServer::loadUrdf(const char* fileName, const btVector3& pos, const b
|
||||
{
|
||||
if (mb)
|
||||
{
|
||||
UrdfLinkNameMapUtil* util = new UrdfLinkNameMapUtil;
|
||||
m_urdfLinkNameMapper.push_back(util);
|
||||
util->m_mb = mb;
|
||||
util->m_memSerializer = new btDefaultSerializer(SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE,(unsigned char*)m_testBlock1->m_bulletStreamDataServerToClient);
|
||||
//disable serialization of the collision objects (they are too big, and the client likely doesn't need them);
|
||||
util->m_memSerializer->m_skipPointers.insert(mb->getBaseCollider(),0);
|
||||
|
||||
for (int i=0;i<mb->getNumLinks();i++)
|
||||
{
|
||||
//disable serialization of the collision objects
|
||||
util->m_memSerializer->m_skipPointers.insert(mb->getLink(i).m_collider,0);
|
||||
int urdfLinkIndex = creation.m_mb2urdfLink[i];
|
||||
std::string* linkName = new std::string(u2b.getLinkName(urdfLinkIndex).c_str());
|
||||
m_strings.push_back(linkName);
|
||||
util->m_memSerializer->registerNameForPointer(linkName->c_str(),linkName->c_str());
|
||||
mb->getLink(i).m_linkName = linkName->c_str();
|
||||
|
||||
std::string* jointName = new std::string(u2b.getJointName(urdfLinkIndex).c_str());
|
||||
m_strings.push_back(jointName);
|
||||
util->m_memSerializer->registerNameForPointer(jointName->c_str(),jointName->c_str());
|
||||
mb->getLink(i).m_jointName = jointName->c_str();
|
||||
}
|
||||
|
||||
std::string* baseName = new std::string(u2b.getLinkName(u2b.getRootLinkIndex()));
|
||||
m_strings.push_back(baseName);
|
||||
|
||||
|
||||
util->m_memSerializer->registerNameForPointer(baseName->c_str(),baseName->c_str());
|
||||
mb->setBaseName(baseName->c_str());
|
||||
|
||||
|
||||
util->m_memSerializer->insertHeader();
|
||||
|
||||
int len = mb->calculateSerializeBufferSize();
|
||||
btChunk* chunk = util->m_memSerializer->allocate(len,1);
|
||||
const char* structType = mb->serialize(chunk->m_oldPtr, util->m_memSerializer);
|
||||
util->m_memSerializer->finalizeChunk(chunk,structType,BT_MULTIBODY_CODE,mb);
|
||||
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
@@ -236,6 +286,10 @@ void PhysicsServer::stepSimulation(float deltaTime)
|
||||
|
||||
if (completedOk)
|
||||
{
|
||||
if (this->m_urdfLinkNameMapper.size())
|
||||
{
|
||||
serverCmd.m_dataStreamArguments.m_streamChunkLength = m_urdfLinkNameMapper.at(m_urdfLinkNameMapper.size()-1)->m_memSerializer->getCurrentBufferSize();
|
||||
}
|
||||
serverCmd.m_type =CMD_URDF_LOADING_COMPLETED;
|
||||
} else
|
||||
{
|
||||
@@ -243,6 +297,9 @@ void PhysicsServer::stepSimulation(float deltaTime)
|
||||
|
||||
}
|
||||
m_testBlock1->m_numServerCommands++;
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
case CMD_REQUEST_ACTUAL_STATE:
|
||||
|
||||
Reference in New Issue
Block a user