Merge remote-tracking branch 'upstream/master'

This commit is contained in:
YunfeiBai
2018-05-03 10:48:55 -07:00
259 changed files with 30418 additions and 14219 deletions

View File

@@ -28,14 +28,14 @@ OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF)
OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" ON)
OPTION(BULLET2_USE_THREAD_LOCKS "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF)
IF (BULLET2_USE_THREAD_LOCKS)
OPTION(BULLET2_MULTITHREADING "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF)
IF (BULLET2_MULTITHREADING)
OPTION(BULLET2_USE_OPEN_MP_MULTITHREADING "Build Bullet 2 with support for multi-threading with OpenMP (requires a compiler with OpenMP support)" OFF)
OPTION(BULLET2_USE_TBB_MULTITHREADING "Build Bullet 2 with support for multi-threading with Intel Threading Building Blocks (requires the TBB library to be already installed)" OFF)
IF (MSVC)
OPTION(BULLET2_USE_PPL_MULTITHREADING "Build Bullet 2 with support for multi-threading with Microsoft Parallel Patterns Library (requires MSVC compiler)" OFF)
ENDIF (MSVC)
ENDIF (BULLET2_USE_THREAD_LOCKS)
ENDIF (BULLET2_MULTITHREADING)
IF(NOT WIN32)
@@ -225,12 +225,15 @@ IF(USE_GRAPHICAL_BENCHMARK)
ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK)
ENDIF (USE_GRAPHICAL_BENCHMARK)
IF(BULLET2_USE_THREAD_LOCKS)
IF(BULLET2_MULTITHREADING)
ADD_DEFINITIONS( -DBT_THREADSAFE=1 )
IF (NOT MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ENDIF (NOT MSVC)
ENDIF (BULLET2_USE_THREAD_LOCKS)
IF (NOT WIN32)
LINK_LIBRARIES( pthread )
ENDIF (NOT WIN32)
ENDIF (BULLET2_MULTITHREADING)
IF (BULLET2_USE_OPEN_MP_MULTITHREADING)
ADD_DEFINITIONS("-DBT_USE_OPENMP=1")

View File

@@ -59,10 +59,7 @@ SET(BulletRobotics_SRCS
../../examples/Utils/b3ReferenceFrameHelper.hpp
../../examples/Utils/ChromeTraceUtil.cpp
../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h

View File

@@ -1,7 +1,7 @@
#ifndef BT_MULTIBODY_WORLD_IMPORTER_H
#define BT_MULTIBODY_WORLD_IMPORTER_H
#include "../Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h"
#include "btBulletWorldImporter.h"
class btMultiBodyWorldImporter : public btBulletWorldImporter
{

View File

@@ -2,6 +2,7 @@ INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/tinyxml2
)
ADD_LIBRARY(
@@ -10,12 +11,7 @@ ADD_LIBRARY(
btBulletXmlWorldImporter.h
string_split.cpp
string_split.h
tinyxml.cpp
tinyxml.h
tinystr.cpp
tinystr.h
tinyxmlerror.cpp
tinyxmlparser.cpp
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
)
SET_TARGET_PROPERTIES(BulletXmlWorldImporter PROPERTIES VERSION ${BULLET_VERSION})

View File

@@ -14,9 +14,10 @@ subject to the following restrictions:
*/
#include "btBulletXmlWorldImporter.h"
#include "tinyxml.h"
#include "tinyxml2.h"
#include "btBulletDynamicsCommon.h"
#include "string_split.h"
using namespace tinyxml2;
struct MyLocalCaster
{
@@ -43,12 +44,12 @@ btBulletXmlWorldImporter::~btBulletXmlWorldImporter()
}
#if 0
static int get_double_attribute_by_name(const TiXmlElement* pElement, const char* attribName,double* value)
static int get_double_attribute_by_name(const XMLElement* pElement, const char* attribName,double* value)
{
if ( !pElement )
return 0;
const TiXmlAttribute* pAttrib=pElement->FirstAttribute();
const XMLAttribute* pAttrib=pElement->FirstAttribute();
while (pAttrib)
{
if (pAttrib->Name()==attribName)
@@ -60,16 +61,16 @@ static int get_double_attribute_by_name(const TiXmlElement* pElement, const char
}
#endif
static int get_int_attribute_by_name(const TiXmlElement* pElement, const char* attribName,int* value)
static int get_int_attribute_by_name(const XMLElement* pElement, const char* attribName,int* value)
{
if ( !pElement )
return 0;
const TiXmlAttribute* pAttrib=pElement->FirstAttribute();
const XMLAttribute* pAttrib=pElement->FirstAttribute();
while (pAttrib)
{
if (!strcmp(pAttrib->Name(),attribName))
if (pAttrib->QueryIntValue(value)==TIXML_SUCCESS)
if (pAttrib->QueryIntValue(value)==XML_SUCCESS)
return 1;
// if (pAttrib->QueryDoubleValue(&dval)==TIXML_SUCCESS) printf( " d=%1.1f", dval);
pAttrib=pAttrib->Next();
@@ -84,7 +85,7 @@ void stringToFloatArray(const std::string& string, btAlignedObjectArray<float>&
bullet_utils::split( pieces, string, " ");
for ( int i = 0; i < pieces.size(); ++i)
{
assert(pieces[i]!="");
btAssert(pieces[i]!="");
floats.push_back((float)atof(pieces[i].c_str()));
}
@@ -95,7 +96,7 @@ static btVector3FloatData TextToVector3Data(const char* txt)
btAssert(txt);
btAlignedObjectArray<float> floats;
stringToFloatArray(txt, floats);
assert(floats.size()==4);
btAssert(floats.size()==4);
btVector3FloatData vec4;
vec4.m_floats[0] = floats[0];
@@ -105,13 +106,13 @@ static btVector3FloatData TextToVector3Data(const char* txt)
return vec4;
}
void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,btAlignedObjectArray<btVector3FloatData>& vectors)
void btBulletXmlWorldImporter::deSerializeVector3FloatData(XMLNode* pParent,btAlignedObjectArray<btVector3FloatData>& vectors)
{
TiXmlNode* flNode = pParent->FirstChild("m_floats");
XMLNode* flNode = pParent->FirstChildElement("m_floats");
btAssert(flNode);
while (flNode && flNode->FirstChild())
while (flNode && flNode->FirstChildElement())
{
TiXmlText* pText = flNode->FirstChild()->ToText();
XMLText* pText = flNode->FirstChildElement()->ToText();
// printf("value = %s\n",pText->Value());
btVector3FloatData vec4 = TextToVector3Data(pText->Value());
vectors.push_back(vec4);
@@ -122,20 +123,20 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
#define SET_INT_VALUE(xmlnode, targetdata, argname) \
btAssert((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement());\
if ((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement())\
(targetdata)->argname= (int)atof(xmlnode->FirstChild(#argname)->ToElement()->GetText());
btAssert((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement());\
if ((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement())\
(targetdata)->argname= (int)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText());
#define SET_FLOAT_VALUE(xmlnode, targetdata, argname) \
btAssert((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement());\
if ((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement())\
(targetdata)->argname= (float)atof(xmlnode->FirstChild(#argname)->ToElement()->GetText());
btAssert((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement());\
if ((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement())\
(targetdata)->argname= (float)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText());
#define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype) \
{\
TiXmlNode* node = xmlnode->FirstChild(#argname);\
XMLNode* node = xmlnode->FirstChildElement(#argname);\
btAssert(node);\
if (node)\
{\
@@ -148,11 +149,11 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
#define SET_VECTOR4_VALUE(xmlnode, targetdata, argname) \
{\
TiXmlNode* flNode = xmlnode->FirstChild(#argname);\
XMLNode* flNode = xmlnode->FirstChildElement(#argname);\
btAssert(flNode);\
if (flNode && flNode->FirstChild())\
if (flNode && flNode->FirstChildElement())\
{\
const char* txt= flNode->FirstChild()->ToElement()->GetText();\
const char* txt= flNode->FirstChildElement()->ToElement()->GetText();\
btVector3FloatData vec4 = TextToVector3Data(txt);\
(targetdata)->argname.m_floats[0] = vec4.m_floats[0];\
(targetdata)->argname.m_floats[1] = vec4.m_floats[1];\
@@ -164,22 +165,22 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
#define SET_MATRIX33_VALUE(n, targetdata, argname) \
{\
TiXmlNode* xmlnode = n->FirstChild(#argname);\
XMLNode* xmlnode = n->FirstChildElement(#argname);\
btAssert(xmlnode);\
if (xmlnode)\
{\
TiXmlNode* eleNode = xmlnode->FirstChild("m_el");\
XMLNode* eleNode = xmlnode->FirstChildElement("m_el");\
btAssert(eleNode);\
if (eleNode&& eleNode->FirstChild())\
if (eleNode&& eleNode->FirstChildElement())\
{\
const char* txt= eleNode->FirstChild()->ToElement()->GetText();\
const char* txt= eleNode->FirstChildElement()->ToElement()->GetText();\
btVector3FloatData vec4 = TextToVector3Data(txt);\
(targetdata)->argname.m_el[0].m_floats[0] = vec4.m_floats[0];\
(targetdata)->argname.m_el[0].m_floats[1] = vec4.m_floats[1];\
(targetdata)->argname.m_el[0].m_floats[2] = vec4.m_floats[2];\
(targetdata)->argname.m_el[0].m_floats[3] = vec4.m_floats[3];\
\
TiXmlNode* n1 = eleNode->FirstChild()->NextSibling();\
XMLNode* n1 = eleNode->FirstChildElement()->NextSibling();\
btAssert(n1);\
if (n1)\
{\
@@ -190,7 +191,7 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
(targetdata)->argname.m_el[1].m_floats[2] = vec4.m_floats[2];\
(targetdata)->argname.m_el[1].m_floats[3] = vec4.m_floats[3];\
\
TiXmlNode* n2 = n1->NextSibling();\
XMLNode* n2 = n1->NextSibling();\
btAssert(n2);\
if (n2)\
{\
@@ -208,7 +209,7 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
#define SET_TRANSFORM_VALUE(n, targetdata, argname) \
{\
TiXmlNode* trNode = n->FirstChild(#argname);\
XMLNode* trNode = n->FirstChildElement(#argname);\
btAssert(trNode);\
if (trNode)\
{\
@@ -218,7 +219,7 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt
}\
void btBulletXmlWorldImporter::deSerializeCollisionShapeData(TiXmlNode* pParent, btCollisionShapeData* colShapeData)
void btBulletXmlWorldImporter::deSerializeCollisionShapeData(XMLNode* pParent, btCollisionShapeData* colShapeData)
{
SET_INT_VALUE(pParent,colShapeData,m_shapeType)
colShapeData->m_name = 0;
@@ -226,17 +227,17 @@ void btBulletXmlWorldImporter::deSerializeCollisionShapeData(TiXmlNode* pParent,
void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(XMLNode* pParent)
{
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btConvexHullShapeData* convexHullData = (btConvexHullShapeData*)btAlignedAlloc(sizeof(btConvexHullShapeData), 16);
TiXmlNode* xmlConvexInt = pParent->FirstChild("m_convexInternalShapeData");
XMLNode* xmlConvexInt = pParent->FirstChildElement("m_convexInternalShapeData");
btAssert(xmlConvexInt);
TiXmlNode* xmlColShape = xmlConvexInt ->FirstChild("m_collisionShapeData");
XMLNode* xmlColShape = xmlConvexInt ->FirstChildElement("m_collisionShapeData");
btAssert(xmlColShape);
deSerializeCollisionShapeData(xmlColShape,&convexHullData->m_convexInternalShapeData.m_collisionShapeData);
@@ -249,7 +250,7 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent
//#define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype)
{
TiXmlNode* node = pParent->FirstChild("m_unscaledPointsFloatPtr");
XMLNode* node = pParent->FirstChildElement("m_unscaledPointsFloatPtr");
btAssert(node);
if (node)
{
@@ -268,7 +269,7 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent
m_pointerLookup.insert(cast.m_ptr,convexHullData);
}
void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(XMLNode* pParent)
{
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
@@ -276,10 +277,10 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar
int numChildren = 0;
btAlignedObjectArray<btCompoundShapeChildData>* compoundChildArrayPtr = new btAlignedObjectArray<btCompoundShapeChildData>;
{
TiXmlNode* transNode = pParent->FirstChild("m_transform");
TiXmlNode* colShapeNode = pParent->FirstChild("m_childShape");
TiXmlNode* marginNode = pParent->FirstChild("m_childMargin");
TiXmlNode* childTypeNode = pParent->FirstChild("m_childShapeType");
XMLNode* transNode = pParent->FirstChildElement("m_transform");
XMLNode* colShapeNode = pParent->FirstChildElement("m_childShape");
XMLNode* marginNode = pParent->FirstChildElement("m_childMargin");
XMLNode* childTypeNode = pParent->FirstChildElement("m_childShapeType");
int i=0;
while (transNode && colShapeNode && marginNode && childTypeNode)
@@ -305,10 +306,10 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar
compoundChildArrayPtr->at(i).m_childMargin = (float)atof(marginNode->ToElement()->GetText());
}
transNode = transNode->NextSibling("m_transform");
colShapeNode = colShapeNode->NextSibling("m_childShape");
marginNode = marginNode->NextSibling("m_childMargin");
childTypeNode = childTypeNode->NextSibling("m_childShapeType");
transNode = transNode->NextSiblingElement("m_transform");
colShapeNode = colShapeNode->NextSiblingElement("m_childShape");
marginNode = marginNode->NextSiblingElement("m_childMargin");
childTypeNode = childTypeNode->NextSiblingElement("m_childShapeType");
i++;
}
@@ -326,24 +327,24 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar
}
void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeCompoundShapeData(XMLNode* pParent)
{
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btCompoundShapeData* compoundData = (btCompoundShapeData*) btAlignedAlloc(sizeof(btCompoundShapeData),16);
TiXmlNode* xmlColShape = pParent ->FirstChild("m_collisionShapeData");
XMLNode* xmlColShape = pParent ->FirstChildElement("m_collisionShapeData");
btAssert(xmlColShape);
deSerializeCollisionShapeData(xmlColShape,&compoundData->m_collisionShapeData);
SET_INT_VALUE(pParent, compoundData,m_numChildShapes);
TiXmlNode* xmlShapeData = pParent->FirstChild("m_collisionShapeData");
XMLNode* xmlShapeData = pParent->FirstChildElement("m_collisionShapeData");
btAssert(xmlShapeData );
{
TiXmlNode* node = pParent->FirstChild("m_childShapePtr");\
XMLNode* node = pParent->FirstChildElement("m_childShapePtr");\
btAssert(node);
while (node)
{
@@ -351,7 +352,7 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent)
MyLocalCaster cast;
cast.m_int = (int) atof(txt);
compoundData->m_childShapePtr = (btCompoundShapeChildData*) cast.m_ptr;
node = node->NextSibling("m_childShapePtr");
node = node->NextSiblingElement("m_childShapePtr");
}
//SET_POINTER_VALUE(xmlColShape, *compoundData,m_childShapePtr,btCompoundShapeChildData*);
@@ -363,14 +364,14 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent)
}
void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(XMLNode* pParent)
{
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*) btAlignedAlloc(sizeof(btStaticPlaneShapeData),16);
TiXmlNode* xmlShapeData = pParent->FirstChild("m_collisionShapeData");
XMLNode* xmlShapeData = pParent->FirstChildElement("m_collisionShapeData");
btAssert(xmlShapeData );
deSerializeCollisionShapeData(xmlShapeData,&planeData->m_collisionShapeData);
@@ -383,7 +384,7 @@ void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParen
}
void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(XMLNode* pParent)
{
btContactSolverInfo solverInfo;
//btVector3 gravity(0,0,0);
@@ -393,7 +394,7 @@ void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(TiXmlNode* pParent)
//gravity and world info
}
void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(XMLNode* pParent)
{
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
@@ -402,7 +403,7 @@ void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pPa
btConvexInternalShapeData* convexShape = (btConvexInternalShapeData*) btAlignedAlloc(sizeof(btConvexInternalShapeData),16);
memset(convexShape,0,sizeof(btConvexInternalShapeData));
TiXmlNode* xmlShapeData = pParent->FirstChild("m_collisionShapeData");
XMLNode* xmlShapeData = pParent->FirstChildElement("m_collisionShapeData");
btAssert(xmlShapeData );
deSerializeCollisionShapeData(xmlShapeData,&convexShape->m_collisionShapeData);
@@ -433,7 +434,7 @@ enum btTypedConstraintType
*/
void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(XMLNode* pParent)
{
MyLocalCaster cast;
get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int);
@@ -441,7 +442,7 @@ void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* p
btGeneric6DofConstraintData2* dof6Data = (btGeneric6DofConstraintData2*)btAlignedAlloc(sizeof(btGeneric6DofConstraintData2),16);
TiXmlNode* n = pParent->FirstChild("m_typeConstraintData");
XMLNode* n = pParent->FirstChildElement("m_typeConstraintData");
if (n)
{
SET_POINTER_VALUE(n,dof6Data->m_typeConstraintData,m_rbA,btRigidBodyData*);
@@ -473,7 +474,7 @@ void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* p
m_pointerLookup.insert(cast.m_ptr,dof6Data);
}
void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent)
void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(XMLNode* pParent)
{
MyLocalCaster cast;
@@ -485,7 +486,7 @@ void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent)
btRigidBodyData* rbData = (btRigidBodyData*)btAlignedAlloc(sizeof(btRigidBodyData),16);
TiXmlNode* n = pParent->FirstChild("m_collisionObjectData");
XMLNode* n = pParent->FirstChildElement("m_collisionObjectData");
if (n)
{
@@ -661,14 +662,14 @@ void btBulletXmlWorldImporter::fixupCollisionDataPointers(btCollisionShapeData*
}
void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pParent)
void btBulletXmlWorldImporter::auto_serialize_root_level_children(XMLNode* pParent)
{
int numChildren = 0;
btAssert(pParent);
if (pParent)
{
TiXmlNode*pChild;
for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling(), numChildren++)
XMLNode*pChild;
for ( pChild = pParent->FirstChildElement(); pChild != 0; pChild = pChild->NextSibling(), numChildren++)
{
// printf("child Name=%s\n", pChild->Value());
if (!strcmp(pChild->Value(),"btVector3FloatData"))
@@ -848,15 +849,15 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa
}
}
void btBulletXmlWorldImporter::auto_serialize(TiXmlNode* pParent)
void btBulletXmlWorldImporter::auto_serialize(XMLNode* pParent)
{
// TiXmlElement* root = pParent->FirstChildElement("bullet_physics");
// XMLElement* root = pParent->FirstChildElement("bullet_physics");
if (pParent)
{
TiXmlNode*pChild;
for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
XMLNode*pChild;
for ( pChild = pParent->FirstChildElement(); pChild != 0; pChild = pChild->NextSibling())
{
if (pChild->Type()==TiXmlNode::TINYXML_ELEMENT)
//if (pChild->Type()==XMLNode::TINYXML_ELEMENT)
{
// printf("root Name=%s\n", pChild->Value());
auto_serialize_root_level_children(pChild);
@@ -873,13 +874,12 @@ void btBulletXmlWorldImporter::auto_serialize(TiXmlNode* pParent)
bool btBulletXmlWorldImporter::loadFile(const char* fileName)
{
TiXmlDocument doc(fileName);
XMLDocument doc;
bool loadOkay = doc.LoadFile();
//dump_to_stdout(&doc,0);
if (loadOkay)
XMLError loadOkay = doc.LoadFile(fileName);
if (loadOkay==XML_SUCCESS)
{
if (get_int_attribute_by_name(doc.FirstChildElement()->ToElement(),"version", &m_fileVersion))
{

View File

@@ -19,7 +19,12 @@ subject to the following restrictions:
#include "LinearMath/btScalar.h"
class btDynamicsWorld;
class TiXmlNode;
namespace tinyxml2
{
class XMLNode;
};
struct btConvexInternalShapeData;
struct btCollisionShapeData;
#ifdef BT_USE_DOUBLE_PRECISION
@@ -40,6 +45,8 @@ struct btCompoundShapeChildData;
#include "LinearMath/btAlignedObjectArray.h"
#include "btWorldImporter.h"
class btBulletXmlWorldImporter : public btWorldImporter
{
@@ -52,28 +59,28 @@ protected:
int m_fileVersion;
bool m_fileOk;
void auto_serialize_root_level_children(TiXmlNode* pParent);
void auto_serialize(TiXmlNode* pParent);
void auto_serialize_root_level_children(tinyxml2::XMLNode* pParent);
void auto_serialize(tinyxml2::XMLNode* pParent);
void deSerializeVector3FloatData(TiXmlNode* pParent,btAlignedObjectArray<btVector3FloatData>& vectors);
void deSerializeVector3FloatData(tinyxml2::XMLNode* pParent,btAlignedObjectArray<btVector3FloatData>& vectors);
void fixupCollisionDataPointers(btCollisionShapeData* shapeData);
void fixupConstraintData(btTypedConstraintData2* tcd);
//collision shapes data
void deSerializeCollisionShapeData(TiXmlNode* pParent,btCollisionShapeData* colShapeData);
void deSerializeConvexInternalShapeData(TiXmlNode* pParent);
void deSerializeStaticPlaneShapeData(TiXmlNode* pParent);
void deSerializeCompoundShapeData(TiXmlNode* pParent);
void deSerializeCompoundShapeChildData(TiXmlNode* pParent);
void deSerializeConvexHullShapeData(TiXmlNode* pParent);
void deSerializeDynamicsWorldData(TiXmlNode* parent);
void deSerializeCollisionShapeData(tinyxml2::XMLNode* pParent,btCollisionShapeData* colShapeData);
void deSerializeConvexInternalShapeData(tinyxml2::XMLNode* pParent);
void deSerializeStaticPlaneShapeData(tinyxml2::XMLNode* pParent);
void deSerializeCompoundShapeData(tinyxml2::XMLNode* pParent);
void deSerializeCompoundShapeChildData(tinyxml2::XMLNode* pParent);
void deSerializeConvexHullShapeData(tinyxml2::XMLNode* pParent);
void deSerializeDynamicsWorldData(tinyxml2::XMLNode* parent);
///bodies
void deSerializeRigidBodyFloatData(TiXmlNode* pParent);
void deSerializeRigidBodyFloatData(tinyxml2::XMLNode* pParent);
///constraints
void deSerializeGeneric6DofConstraintData(TiXmlNode* pParent);
void deSerializeGeneric6DofConstraintData(tinyxml2::XMLNode* pParent);
public:
btBulletXmlWorldImporter(btDynamicsWorld* world);

View File

@@ -5,10 +5,12 @@
includedirs {
"../BulletWorldImporter",
"../BulletFileLoader",
"../../../src"
"../../../src",
"../../../examples/ThirdPartyLibs/tinyxml2"
}
files {
"**.cpp",
"**.h"
"**.h",
"../../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
}

View File

@@ -1,111 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef TIXML_USE_STL
#include "tinystr.h"
// Error value for find primitive
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
// Null rep.
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
void TiXmlString::reserve (size_type cap)
{
if (cap > capacity())
{
TiXmlString tmp;
tmp.init(length(), cap);
memcpy(tmp.start(), data(), length());
swap(tmp);
}
}
TiXmlString& TiXmlString::assign(const char* str, size_type len)
{
size_type cap = capacity();
if (len > cap || cap > 3*(len + 8))
{
TiXmlString tmp;
tmp.init(len);
memcpy(tmp.start(), str, len);
swap(tmp);
}
else
{
memmove(start(), str, len);
set_size(len);
}
return *this;
}
TiXmlString& TiXmlString::append(const char* str, size_type len)
{
size_type newsize = length() + len;
if (newsize > capacity())
{
reserve (newsize + capacity());
}
memmove(finish(), str, len);
set_size(newsize);
return *this;
}
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
{
TiXmlString tmp;
tmp.reserve(a.length() + b.length());
tmp += a;
tmp += b;
return tmp;
}
TiXmlString operator + (const TiXmlString & a, const char* b)
{
TiXmlString tmp;
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
tmp.reserve(a.length() + b_len);
tmp += a;
tmp.append(b, b_len);
return tmp;
}
TiXmlString operator + (const char* a, const TiXmlString & b)
{
TiXmlString tmp;
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
tmp.reserve(a_len + b.length());
tmp.append(a, a_len);
tmp += b;
return tmp;
}
#endif // TIXML_USE_STL

View File

@@ -1,305 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef TIXML_USE_STL
#ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED
#include <assert.h>
#include <string.h>
/* The support for explicit isn't that universal, and it isn't really
required - it is used to check that the TiXmlString class isn't incorrectly
used. Be nice to old compilers and macro it here:
*/
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
// Microsoft visual studio, version 6 and higher.
#define TIXML_EXPLICIT explicit
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
// GCC version 3 and higher.s
#define TIXML_EXPLICIT explicit
#else
#define TIXML_EXPLICIT
#endif
/*
TiXmlString is an emulation of a subset of the std::string template.
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
Only the member functions relevant to the TinyXML project have been implemented.
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
a string and there's no more room, we allocate a buffer twice as big as we need.
*/
class TiXmlString
{
public :
// The size type used
typedef size_t size_type;
// Error value for find primitive
static const size_type npos; // = -1;
// TiXmlString empty constructor
TiXmlString () : rep_(&nullrep_)
{
}
// TiXmlString copy constructor
TiXmlString ( const TiXmlString & copy) : rep_(0)
{
init(copy.length());
memcpy(start(), copy.data(), length());
}
// TiXmlString constructor, based on a string
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
{
init( static_cast<size_type>( strlen(copy) ));
memcpy(start(), copy, length());
}
// TiXmlString constructor, based on a string
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
{
init(len);
memcpy(start(), str, len);
}
// TiXmlString destructor
~TiXmlString ()
{
quit();
}
TiXmlString& operator = (const char * copy)
{
return assign( copy, (size_type)strlen(copy));
}
TiXmlString& operator = (const TiXmlString & copy)
{
return assign(copy.start(), copy.length());
}
// += operator. Maps to append
TiXmlString& operator += (const char * suffix)
{
return append(suffix, static_cast<size_type>( strlen(suffix) ));
}
// += operator. Maps to append
TiXmlString& operator += (char single)
{
return append(&single, 1);
}
// += operator. Maps to append
TiXmlString& operator += (const TiXmlString & suffix)
{
return append(suffix.data(), suffix.length());
}
// Convert a TiXmlString into a null-terminated char *
const char * c_str () const { return rep_->str; }
// Convert a TiXmlString into a char * (need not be null terminated).
const char * data () const { return rep_->str; }
// Return the length of a TiXmlString
size_type length () const { return rep_->size; }
// Alias for length()
size_type size () const { return rep_->size; }
// Checks if a TiXmlString is empty
bool empty () const { return rep_->size == 0; }
// Return capacity of string
size_type capacity () const { return rep_->capacity; }
// single char extraction
const char& at (size_type index) const
{
assert( index < length() );
return rep_->str[ index ];
}
// [] operator
char& operator [] (size_type index) const
{
assert( index < length() );
return rep_->str[ index ];
}
// find a char in a string. Return TiXmlString::npos if not found
size_type find (char lookup) const
{
return find(lookup, 0);
}
// find a char in a string from an offset. Return TiXmlString::npos if not found
size_type find (char tofind, size_type offset) const
{
if (offset >= length()) return npos;
for (const char* p = c_str() + offset; *p != '\0'; ++p)
{
if (*p == tofind) return static_cast< size_type >( p - c_str() );
}
return npos;
}
void clear ()
{
//Lee:
//The original was just too strange, though correct:
// TiXmlString().swap(*this);
//Instead use the quit & re-init:
quit();
init(0,0);
}
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
function DOES NOT clear the content of the TiXmlString if any exists.
*/
void reserve (size_type cap);
TiXmlString& assign (const char* str, size_type len);
TiXmlString& append (const char* str, size_type len);
void swap (TiXmlString& other)
{
Rep* r = rep_;
rep_ = other.rep_;
other.rep_ = r;
}
private:
void init(size_type sz) { init(sz, sz); }
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
char* start() const { return rep_->str; }
char* finish() const { return rep_->str + rep_->size; }
struct Rep
{
size_type size, capacity;
char str[1];
};
void init(size_type sz, size_type cap)
{
if (cap)
{
// Lee: the original form:
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
// doesn't work in some cases of new being overloaded. Switching
// to the normal allocation, although use an 'int' for systems
// that are overly picky about structure alignment.
const size_type bytesNeeded = sizeof(Rep) + cap;
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
rep_->str[ rep_->size = sz ] = '\0';
rep_->capacity = cap;
}
else
{
rep_ = &nullrep_;
}
}
void quit()
{
if (rep_ != &nullrep_)
{
// The rep_ is really an array of ints. (see the allocator, above).
// Cast it back before delete, so the compiler won't incorrectly call destructors.
delete [] ( reinterpret_cast<int*>( rep_ ) );
}
}
Rep * rep_;
static Rep nullrep_;
} ;
inline bool operator == (const TiXmlString & a, const TiXmlString & b)
{
return ( a.length() == b.length() ) // optimization on some platforms
&& ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
}
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
{
return strcmp(a.c_str(), b.c_str()) < 0;
}
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
TiXmlString operator + (const TiXmlString & a, const char* b);
TiXmlString operator + (const char* a, const TiXmlString & b);
/*
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
Only the operators that we need for TinyXML have been developped.
*/
class TiXmlOutStream : public TiXmlString
{
public :
// TiXmlOutStream << operator.
TiXmlOutStream & operator << (const TiXmlString & in)
{
*this += in;
return *this;
}
// TiXmlOutStream << operator.
TiXmlOutStream & operator << (const char * in)
{
*this += in;
return *this;
}
} ;
#endif // TIXML_STRING_INCLUDED
#endif // TIXML_USE_STL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// english error messages, but the could now be translated.
//
// It also cleans up the code a bit.
//
const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty.",
"Error null (0) or unexpected EOF found in input stream.",
"Error parsing CDATA.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
};

File diff suppressed because it is too large Load Diff

View File

@@ -80,9 +80,9 @@ Depending on your system (Linux 32bit, 64bit or Mac OSX) use one of the followin
Using premake:
```
cd build3
./premake4_linux gmake --double
./premake4_linux64 gmake --double
./premake4_osx gmake --double --enable_pybullet
./premake4_linux --double gmake
./premake4_linux64 --double gmake
./premake4_osx --double --enable_pybullet gmake
```
Then
```

View File

@@ -182,6 +182,14 @@ end
trigger = "audio",
description = "Enable audio"
}
newoption
{
trigger = "enable_multithreading",
description = "enable CPU multithreading for bullet2 libs"
}
if _OPTIONS["enable_multithreading"] then
defines {"BT_THREADSAFE=1"}
end
if _OPTIONS["double"] then
defines {"BT_USE_DOUBLE_PRECISION"}
end

11
data/mjcf/sphere.xml Normal file
View File

@@ -0,0 +1,11 @@
<!--
MuJoCo MJCF test file. See http://mujoco.org/book/index.html
-->
<mujoco>
<worldbody>
<body pos="0 0 0">
<joint type="free"/>
<geom name="sphere_geom" size="0.05" type="sphere"/>
</body>
</worldbody>
</mujoco>

View File

@@ -9,6 +9,6 @@ newmtl Material
Kd 0.5880 0.5880 0.5880
Ks 0.0000 0.0000 0.0000
Ke 0.0000 0.0000 0.0000
map_Kd tex4x4.png
map_Kd checker_blue.png

View File

@@ -7,9 +7,9 @@ v 15.000000 15.000000 0.000000
v -15.000000 15.000000 0.000000
v -15.000000 -15.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vt 15.000000 0.000000
vt 15.000000 15.000000
vt 0.000000 15.000000
vt 0.000000 0.000000
usemtl Material

View File

@@ -12,7 +12,7 @@
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="plane.obj" scale="1 1 1"/>
<mesh filename="plane_transparent.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 .7"/>

BIN
data/toys/concave_box.cdf Normal file

Binary file not shown.

11
data/toys/concave_box.mtl Normal file
View File

@@ -0,0 +1,11 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl None
Ns 0
Ka 0.000000 0.000000 0.000000
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2
map_Kd ../checker_grid.jpg

949
data/toys/concave_box.obj Normal file
View File

@@ -0,0 +1,949 @@
# Blender v2.78 (sub 0) OBJ File: ''
# www.blender.org
mtllib concave_box.mtl
o Cube_Cube.003
v 0.252358 -0.051546 0.073254
v 0.196823 -0.040500 0.026785
v 0.133463 -0.027897 -0.007745
v 0.064714 -0.014222 -0.029009
v 0.237323 -0.101112 0.073254
v 0.185009 -0.079443 0.026785
v 0.125326 -0.054721 -0.007745
v 0.060565 -0.027897 -0.029009
v 0.212906 -0.146792 0.073254
v 0.165826 -0.115334 0.026785
v 0.112112 -0.079443 -0.007745
v 0.053829 -0.040500 -0.029009
v 0.180047 -0.186831 0.073254
v 0.140008 -0.146792 0.026785
v 0.094329 -0.101112 -0.007745
v 0.044763 -0.051546 -0.029009
v 0.140008 -0.219690 0.073254
v 0.108550 -0.172609 0.026785
v 0.072660 -0.118895 -0.007745
v 0.033716 -0.060612 -0.029009
v -0.006783 -0.000000 -0.036189
v 0.094329 -0.244106 0.073254
v 0.072660 -0.191793 0.026785
v 0.047938 -0.132109 -0.007745
v 0.021113 -0.067349 -0.029009
v 0.044763 -0.259142 0.073254
v 0.033716 -0.203606 0.026785
v 0.021113 -0.140246 -0.007745
v 0.007438 -0.071497 -0.029009
v -0.006783 -0.264218 0.073254
v -0.006783 -0.207595 0.026785
v -0.006783 -0.142994 -0.007745
v -0.006783 -0.072898 -0.029009
v -0.058330 -0.259142 0.073254
v -0.047283 -0.203606 0.026785
v -0.034680 -0.140246 -0.007745
v -0.021005 -0.071497 -0.029009
v -0.107895 -0.244106 0.073254
v -0.086227 -0.191793 0.026785
v -0.061505 -0.132109 -0.007745
v -0.034680 -0.067349 -0.029009
v -0.153575 -0.219690 0.073254
v -0.122117 -0.172609 0.026785
v -0.086227 -0.118895 -0.007745
v -0.047283 -0.060612 -0.029009
v -0.193614 -0.186831 0.073254
v -0.153575 -0.146792 0.026785
v -0.107895 -0.101112 -0.007745
v -0.058330 -0.051546 -0.029009
v -0.226473 -0.146792 0.073254
v -0.179392 -0.115334 0.026785
v -0.125679 -0.079443 -0.007745
v -0.067396 -0.040500 -0.029009
v -0.250889 -0.101112 0.073254
v -0.198576 -0.079443 0.026785
v -0.138893 -0.054721 -0.007745
v -0.074132 -0.027897 -0.029009
v -0.265925 -0.051546 0.073254
v -0.210390 -0.040500 0.026785
v -0.147030 -0.027897 -0.007745
v -0.078280 -0.014222 -0.029009
v -0.271002 0.000000 0.073254
v -0.214378 0.000000 0.026785
v -0.149777 -0.000000 -0.007745
v -0.079681 -0.000000 -0.029009
v -0.265925 0.051546 0.073254
v -0.210390 0.040500 0.026785
v -0.147030 0.027897 -0.007745
v -0.078280 0.014222 -0.029009
v -0.250889 0.101112 0.073254
v -0.198576 0.079443 0.026785
v -0.138893 0.054721 -0.007745
v -0.074132 0.027897 -0.029009
v -0.226473 0.146792 0.073254
v -0.179392 0.115334 0.026785
v -0.125679 0.079443 -0.007745
v -0.067396 0.040500 -0.029009
v -0.193614 0.186831 0.073254
v -0.153575 0.146792 0.026785
v -0.107895 0.101112 -0.007745
v -0.058330 0.051546 -0.029009
v -0.153575 0.219690 0.073254
v -0.122117 0.172609 0.026785
v -0.086227 0.118895 -0.007745
v -0.047283 0.060612 -0.029009
v -0.107895 0.244106 0.073254
v -0.086227 0.191793 0.026785
v -0.061505 0.132109 -0.007745
v -0.034680 0.067349 -0.029009
v -0.058330 0.259141 0.073254
v -0.047283 0.203606 0.026785
v -0.034680 0.140246 -0.007745
v -0.021005 0.071497 -0.029009
v -0.006783 0.264218 0.073254
v -0.006783 0.207595 0.026785
v -0.006783 0.142994 -0.007745
v -0.006783 0.072898 -0.029009
v 0.044763 0.259141 0.073254
v 0.033716 0.203606 0.026785
v 0.021113 0.140246 -0.007745
v 0.007438 0.071497 -0.029009
v 0.094329 0.244106 0.073254
v 0.072660 0.191793 0.026785
v 0.047938 0.132109 -0.007745
v 0.021113 0.067349 -0.029009
v 0.140008 0.219689 0.073254
v 0.108550 0.172609 0.026785
v 0.072660 0.118895 -0.007745
v 0.033716 0.060612 -0.029009
v 0.180047 0.186831 0.073254
v 0.140008 0.146792 0.026785
v 0.094328 0.101112 -0.007745
v 0.044763 0.051546 -0.029009
v 0.212906 0.146792 0.073254
v 0.165825 0.115334 0.026785
v 0.112112 0.079443 -0.007745
v 0.053829 0.040500 -0.029009
v 0.237322 0.101112 0.073254
v 0.185009 0.079443 0.026785
v 0.125326 0.054721 -0.007745
v 0.060565 0.027897 -0.029009
v 0.252358 0.051546 0.073254
v 0.196823 0.040500 0.026785
v 0.133463 0.027897 -0.007745
v 0.064713 0.014222 -0.029009
v 0.257435 -0.000000 0.073254
v 0.200811 -0.000000 0.026785
v 0.136210 -0.000000 -0.007745
v 0.066114 -0.000000 -0.029009
v -1.000000 1.000000 -0.100000
v -1.000000 1.000000 0.100000
v 1.000000 1.000000 -0.100000
v 1.000000 1.000000 0.100000
v -1.000000 -1.000000 -0.100000
v -1.000000 -1.000000 0.100000
v 1.000000 -1.000000 -0.100000
v 1.000000 -1.000000 0.100000
v -0.006783 -0.286168 0.100000
v -0.062612 -0.280669 0.100000
v 0.195568 -0.202351 0.100000
v 0.231157 -0.158987 0.100000
v 0.257601 -0.109512 0.100000
v 0.195568 0.202351 0.100000
v -0.209135 0.202351 0.100000
v 0.273886 -0.055829 0.100000
v 0.273886 0.055829 0.100000
v 0.257601 0.109512 0.100000
v 0.152203 0.237940 0.100000
v -0.209135 -0.202351 0.100000
v -0.165770 -0.237940 0.100000
v -0.244724 -0.158986 0.100000
v -0.116295 -0.264385 0.100000
v -0.244723 0.158986 0.100000
v -0.165770 0.237940 0.100000
v -0.116295 0.264385 0.100000
v 0.231156 0.158986 0.100000
v -0.271168 -0.109512 0.100000
v -0.287453 0.055829 0.100000
v -0.292951 0.000000 0.100000
v 0.279384 -0.000000 0.100000
v 0.102728 -0.264385 0.100000
v 0.049045 0.280669 0.100000
v 0.049045 -0.280669 0.100000
v -0.287453 -0.055829 0.100000
v -0.062612 0.280669 0.100000
v -0.006783 0.286168 0.100000
v 0.152203 -0.237940 0.100000
v 0.102728 0.264385 0.100000
v -0.271168 0.109512 0.100000
vt 0.5258 0.8663
vt 0.5000 1.0000
vt 0.5000 0.8663
vt 0.5202 0.6339
vt 0.5000 0.6339
vt 0.5139 0.4613
vt 0.5000 0.4613
vt 0.5071 0.3550
vt 0.5000 0.3550
vt 0.5000 0.4966
vt 0.5071 0.5324
vt 0.5000 0.5331
vt 0.5139 0.5303
vt 0.5506 0.8663
vt 0.5279 1.0000
vt 0.5274 0.4613
vt 0.5139 0.3550
vt 0.5734 0.8663
vt 0.5548 1.0000
vt 0.5577 0.6339
vt 0.5397 0.6339
vt 0.5397 0.4613
vt 0.5202 0.3550
vt 0.5202 0.5269
vt 0.5258 0.5224
vt 0.6012 1.0000
vt 0.5795 1.0000
vt 0.5734 0.6339
vt 0.5506 0.4613
vt 0.5258 0.3550
vt 0.5700 0.6339
vt 0.5700 0.8663
vt 0.5900 0.8663
vt 0.5363 0.4613
vt 0.5472 0.4613
vt 0.5169 0.3550
vt 0.5224 0.3550
vt 0.5303 0.5169
vt 0.5978 1.0000
vt 0.5514 1.0000
vt 0.5761 1.0000
vt 0.5543 0.6339
vt 0.5472 0.8663
vt 0.5363 0.6339
vt 0.5240 0.4613
vt 0.5337 0.5106
vt 0.5224 0.8663
vt 0.5106 0.4613
vt 0.5106 0.3550
vt 0.5357 0.5037
vt 0.4966 1.0000
vt 0.5245 1.0000
vt 0.5169 0.6339
vt 0.4966 0.8663
vt 0.4966 0.6339
vt 0.5037 0.3550
vt 0.4966 0.4613
vt 0.5364 0.4966
vt 0.4827 0.4613
vt 0.4895 0.3550
vt 0.4966 0.3550
vt 0.5357 0.4895
vt 0.4708 0.8663
vt 0.4461 0.8663
vt 0.4687 1.0000
vt 0.4764 0.6339
vt 0.4569 0.6339
vt 0.4692 0.4613
vt 0.5337 0.4827
vt 0.4827 0.3550
vt 0.4569 0.4613
vt 0.5303 0.4764
vt 0.4232 0.8663
vt 0.4419 1.0000
vt 0.4389 0.6339
vt 0.4032 0.8663
vt 0.4171 1.0000
vt 0.4232 0.6339
vt 0.4708 0.3550
vt 0.4764 0.3550
vt 0.5258 0.4708
vt 0.5202 0.3550
vt 0.5506 0.4613
vt 0.5258 0.3550
vt 0.5202 0.4663
vt 0.5734 0.8663
vt 0.6012 1.0000
vt 0.5934 0.8663
vt 0.5734 0.6339
vt 0.5577 0.6339
vt 0.5506 0.8663
vt 0.5795 1.0000
vt 0.5274 0.4613
vt 0.5397 0.4613
vt 0.5139 0.4629
vt 0.5071 0.4609
vt 0.5279 1.0000
vt 0.5548 1.0000
vt 0.5202 0.6339
vt 0.5397 0.6339
vt 0.5139 0.4613
vt 0.5071 0.3550
vt 0.5139 0.3550
vt 0.5000 0.8663
vt 0.5258 0.8663
vt 0.5000 0.6339
vt 0.5000 0.4613
vt 0.5000 0.4602
vt 0.4929 0.4609
vt 0.4742 0.8663
vt 0.5000 1.0000
vt 0.4798 0.6339
vt 0.4861 0.4613
vt 0.4929 0.3550
vt 0.5000 0.3550
vt 0.4603 0.6339
vt 0.4726 0.4613
vt 0.4861 0.4629
vt 0.4494 0.8663
vt 0.4721 1.0000
vt 0.4266 0.8663
vt 0.4452 1.0000
vt 0.4603 0.4613
vt 0.4861 0.3550
vt 0.4798 0.4663
vt 0.4266 0.6339
vt 0.4423 0.6339
vt 0.4742 0.3550
vt 0.4798 0.3550
vt 0.4742 0.4708
vt 0.4066 0.8663
vt 0.4205 1.0000
vt 0.4232 0.8663
vt 0.3954 1.0000
vt 0.4032 0.8663
vt 0.4389 0.6339
vt 0.4232 0.6339
vt 0.4569 0.4613
vt 0.4461 0.4613
vt 0.4708 0.3550
vt 0.4697 0.4764
vt 0.4569 0.6339
vt 0.4827 0.3550
vt 0.4764 0.3550
vt 0.4663 0.4827
vt 0.4461 0.8663
vt 0.4171 1.0000
vt 0.4708 0.8663
vt 0.4419 1.0000
vt 0.4764 0.6339
vt 0.4827 0.4613
vt 0.4692 0.4613
vt 0.4895 0.3550
vt 0.4643 0.4895
vt 0.4966 0.3550
vt 0.4636 0.4966
vt 0.4966 0.8663
vt 0.4687 1.0000
vt 0.4966 0.6339
vt 0.5224 0.8663
vt 0.4966 1.0000
vt 0.5169 0.6339
vt 0.4966 0.4613
vt 0.5037 0.3550
vt 0.4643 0.5037
vt 0.5106 0.3550
vt 0.5106 0.4613
vt 0.4663 0.5106
vt 0.5472 0.8663
vt 0.5245 1.0000
vt 0.5363 0.6339
vt 0.5240 0.4613
vt 0.5700 0.8663
vt 0.5514 1.0000
vt 0.5363 0.4613
vt 0.5169 0.3550
vt 0.4697 0.5169
vt 0.4742 0.5224
vt 0.5900 0.8663
vt 0.5761 1.0000
vt 0.5700 0.6339
vt 0.5543 0.6339
vt 0.5224 0.3550
vt 0.4423 0.6339
vt 0.4066 0.8663
vt 0.4266 0.6339
vt 0.4603 0.4613
vt 0.4494 0.4613
vt 0.4798 0.3550
vt 0.4742 0.3550
vt 0.4798 0.5269
vt 0.4266 0.8663
vt 0.3988 1.0000
vt 0.4494 0.8663
vt 0.4205 1.0000
vt 0.4603 0.6339
vt 0.4861 0.3550
vt 0.4861 0.5303
vt 0.4798 0.6339
vt 0.4861 0.4613
vt 0.4726 0.4613
vt 0.4929 0.3550
vt 0.4929 0.5324
vt 0.4742 0.8663
vt 0.4452 1.0000
vt 0.4721 1.0000
vt 0.0000 1.0000
vt 1.0000 0.0000
vt 0.0000 0.0000
vt 0.0000 1.0000
vt 1.0000 0.0000
vt 0.0000 0.0000
vt 0.0000 1.0000
vt -1.0000 0.0000
vt 0.0000 0.0000
vt 0.0000 1.0000
vt -1.0000 0.0000
vt 0.0000 0.0000
vt 0.0000 -1.0000
vt -1.0000 0.0000
vt -0.5279 -0.3631
vt -0.5000 -0.3603
vt -0.5000 0.3535
vt -0.5279 0.3563
vt -1.0000 0.0000
vt 0.5934 0.8663
vt 0.3954 1.0000
vt 0.4461 0.4613
vt 0.4494 0.4613
vt 0.3988 1.0000
vt 0.5978 1.0000
vt 0.5472 0.4613
vt 1.0000 1.0000
vt 1.0000 1.0000
vt -1.0000 1.0000
vt -1.0000 1.0000
vt 1.0000 -1.0000
vt -1.0000 -1.0000
vt -0.6431 -0.5034
vt -0.6403 -0.4755
vt -0.3569 -0.5034
vt 0.0000 -1.0000
vt 0.0000 0.0000
vt -0.3597 -0.4755
vt -0.6322 -0.4486
vt -0.6190 -0.4239
vt -0.3678 -0.4486
vt -0.3810 -0.4239
vt -0.6012 -0.4022
vt -0.5795 -0.3844
vt -0.3988 -0.4022
vt -0.4205 -0.3844
vt -0.5548 -0.3712
vt -0.4452 -0.3712
vt -0.4721 -0.3631
vt 0.0000 0.0000
vt -0.3569 0.4966
vt -0.3597 0.4687
vt -0.3678 0.4419
vt -0.6403 0.4687
vt -0.6431 0.4966
vt -0.6322 0.4419
vt -0.3810 0.4171
vt -0.3988 0.3954
vt -0.6190 0.4171
vt -0.6012 0.3954
vt -0.4205 0.3776
vt -0.4452 0.3644
vt -0.5795 0.3776
vt -0.5548 0.3644
vt -0.4721 0.3563
vn -0.7708 0.0759 0.6326
vn -0.6332 0.0624 0.7715
vn -0.4709 0.0464 0.8810
vn -0.2902 0.0286 0.9565
vn -0.0980 0.0097 0.9951
vn -0.0942 0.0286 0.9951
vn -0.7412 0.2248 0.6326
vn -0.6088 0.1847 0.7715
vn -0.4528 0.1374 0.8810
vn -0.2790 0.0846 0.9565
vn -0.6831 0.3651 0.6326
vn -0.5611 0.2999 0.7715
vn -0.4173 0.2230 0.8810
vn -0.2571 0.1374 0.9565
vn -0.0869 0.0464 0.9951
vn -0.0761 0.0625 0.9951
vn -0.5987 0.4913 0.6326
vn -0.4918 0.4036 0.7715
vn -0.3658 0.3002 0.8810
vn -0.2254 0.1850 0.9565
vn -0.4036 0.4918 0.7715
vn -0.3002 0.3658 0.8810
vn -0.1850 0.2254 0.9565
vn -0.0625 0.0761 0.9951
vn -0.4913 0.5987 0.6326
vn -0.3651 0.6831 0.6326
vn -0.2999 0.5611 0.7715
vn -0.2230 0.4173 0.8810
vn -0.1374 0.2571 0.9565
vn -0.0464 0.0869 0.9951
vn -0.1847 0.6088 0.7715
vn -0.1374 0.4528 0.8810
vn -0.0846 0.2790 0.9565
vn -0.0286 0.0942 0.9951
vn -0.2248 0.7412 0.6326
vn -0.0759 0.7708 0.6326
vn -0.0624 0.6332 0.7715
vn -0.0464 0.4709 0.8810
vn -0.0286 0.2902 0.9565
vn -0.0097 0.0980 0.9951
vn 0.0464 0.4709 0.8810
vn 0.0286 0.2902 0.9565
vn 0.0097 0.0980 0.9951
vn 0.0759 0.7708 0.6326
vn 0.0624 0.6332 0.7715
vn 0.2248 0.7412 0.6326
vn 0.1847 0.6088 0.7715
vn 0.1374 0.4528 0.8810
vn 0.0846 0.2790 0.9565
vn 0.0286 0.0942 0.9951
vn 0.1374 0.2571 0.9565
vn 0.0464 0.0869 0.9951
vn 0.3651 0.6831 0.6326
vn 0.2999 0.5611 0.7715
vn 0.2230 0.4173 0.8810
vn 0.4913 0.5987 0.6326
vn 0.4036 0.4918 0.7715
vn 0.3002 0.3658 0.8810
vn 0.1850 0.2254 0.9565
vn 0.0625 0.0761 0.9951
vn 0.2254 0.1850 0.9565
vn 0.0761 0.0625 0.9951
vn 0.5987 0.4913 0.6326
vn 0.4918 0.4036 0.7715
vn 0.3658 0.3002 0.8810
vn 0.6831 0.3651 0.6326
vn 0.5611 0.2999 0.7715
vn 0.4173 0.2230 0.8810
vn 0.2571 0.1374 0.9565
vn 0.0869 0.0464 0.9951
vn 0.0942 0.0286 0.9951
vn 0.7412 0.2248 0.6326
vn 0.6088 0.1847 0.7715
vn 0.4528 0.1374 0.8810
vn 0.2790 0.0846 0.9565
vn 0.7708 0.0759 0.6326
vn 0.6332 0.0624 0.7715
vn 0.4709 0.0464 0.8810
vn 0.2902 0.0286 0.9565
vn 0.0980 0.0097 0.9951
vn 0.0980 -0.0097 0.9951
vn 0.7708 -0.0759 0.6326
vn 0.6332 -0.0624 0.7715
vn 0.4709 -0.0464 0.8810
vn 0.2902 -0.0286 0.9565
vn 0.6088 -0.1847 0.7715
vn 0.4528 -0.1374 0.8810
vn 0.2790 -0.0846 0.9565
vn 0.0942 -0.0286 0.9951
vn 0.7412 -0.2248 0.6326
vn 0.6831 -0.3651 0.6326
vn 0.5611 -0.2999 0.7715
vn 0.4173 -0.2230 0.8810
vn 0.2571 -0.1374 0.9565
vn 0.0869 -0.0464 0.9951
vn 0.3658 -0.3002 0.8810
vn 0.2254 -0.1850 0.9565
vn 0.0761 -0.0625 0.9951
vn 0.5987 -0.4913 0.6326
vn 0.4918 -0.4036 0.7715
vn 0.4913 -0.5987 0.6326
vn 0.4036 -0.4918 0.7715
vn 0.3002 -0.3658 0.8810
vn 0.1850 -0.2254 0.9565
vn 0.0625 -0.0761 0.9951
vn 0.2230 -0.4173 0.8810
vn 0.1374 -0.2571 0.9565
vn 0.0464 -0.0869 0.9951
vn 0.3651 -0.6831 0.6326
vn 0.2999 -0.5611 0.7715
vn 0.2248 -0.7412 0.6326
vn 0.1847 -0.6088 0.7715
vn 0.1374 -0.4528 0.8810
vn 0.0846 -0.2790 0.9565
vn 0.0286 -0.0942 0.9951
vn 0.0286 -0.2902 0.9565
vn 0.0097 -0.0980 0.9951
vn 0.0759 -0.7708 0.6326
vn 0.0624 -0.6332 0.7715
vn 0.0464 -0.4709 0.8810
vn -0.0759 -0.7708 0.6326
vn -0.0624 -0.6332 0.7715
vn -0.0464 -0.4709 0.8810
vn -0.0286 -0.2902 0.9565
vn -0.0097 -0.0980 0.9951
vn -0.0846 -0.2790 0.9565
vn -0.0286 -0.0942 0.9951
vn -0.2248 -0.7412 0.6326
vn -0.1847 -0.6088 0.7715
vn -0.1374 -0.4528 0.8810
vn -0.3651 -0.6831 0.6326
vn -0.2999 -0.5611 0.7715
vn -0.2231 -0.4173 0.8810
vn -0.1374 -0.2571 0.9565
vn -0.0464 -0.0869 0.9951
vn -0.0625 -0.0761 0.9951
vn -0.4913 -0.5987 0.6326
vn -0.4036 -0.4918 0.7715
vn -0.3002 -0.3658 0.8810
vn -0.1850 -0.2254 0.9565
vn -0.4918 -0.4036 0.7715
vn -0.3658 -0.3002 0.8810
vn -0.2254 -0.1850 0.9565
vn -0.0761 -0.0625 0.9951
vn -0.5987 -0.4913 0.6326
vn -0.6831 -0.3651 0.6326
vn -0.5611 -0.2999 0.7715
vn -0.4173 -0.2231 0.8810
vn -0.2571 -0.1374 0.9565
vn -0.0869 -0.0464 0.9951
vn -0.6088 -0.1847 0.7715
vn -0.4528 -0.1374 0.8810
vn -0.2790 -0.0846 0.9565
vn -0.0942 -0.0286 0.9951
vn -0.7412 -0.2248 0.6326
vn -0.7708 -0.0759 0.6326
vn -0.6332 -0.0624 0.7715
vn -0.4709 -0.0464 0.8810
vn -0.2902 -0.0286 0.9565
vn -0.0980 -0.0097 0.9951
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn -0.0000 0.0000 1.0000
vn 0.2231 0.4173 0.8810
vn 0.4173 -0.2231 0.8810
vn -0.4173 -0.2230 0.8810
usemtl None
s off
f 1/1/1 160/2/1 126/3/1
f 2/4/2 126/3/2 127/5/2
f 3/6/3 127/5/3 128/7/3
f 4/8/4 128/7/4 129/9/4
f 21/10/5 4/11/5 129/12/5
f 21/10/6 8/13/6 4/11/6
f 5/14/7 145/15/7 1/1/7
f 2/4/8 5/14/8 1/1/8
f 7/16/9 2/4/9 3/6/9
f 8/17/10 3/6/10 4/8/10
f 9/18/11 142/19/11 5/14/11
f 10/20/12 5/14/12 6/21/12
f 11/22/13 6/21/13 7/16/13
f 12/23/14 7/16/14 8/17/14
f 21/10/15 12/24/15 8/13/15
f 21/10/16 16/25/16 12/24/16
f 9/18/17 140/26/17 141/27/17
f 14/28/18 9/18/18 10/20/18
f 15/29/19 10/20/19 11/22/19
f 16/30/20 11/22/20 12/23/20
f 14/31/21 17/32/21 13/33/21
f 19/34/22 14/31/22 15/35/22
f 20/36/23 15/35/23 16/37/23
f 21/10/24 20/38/24 16/25/24
f 17/32/25 140/39/25 13/33/25
f 17/32/26 161/40/26 167/41/26
f 18/42/27 22/43/27 17/32/27
f 19/34/28 23/44/28 18/42/28
f 20/36/29 24/45/29 19/34/29
f 21/10/30 25/46/30 20/38/30
f 23/44/31 26/47/31 22/43/31
f 28/48/32 23/44/32 24/45/32
f 25/49/33 28/48/33 24/45/33
f 21/10/34 29/50/34 25/46/34
f 26/47/35 161/40/35 22/43/35
f 26/47/36 138/51/36 163/52/36
f 27/53/37 30/54/37 26/47/37
f 28/48/38 31/55/38 27/53/38
f 29/56/39 32/57/39 28/48/39
f 21/10/40 33/58/40 29/50/40
f 36/59/41 31/55/41 32/57/41
f 37/60/42 32/57/42 33/61/42
f 21/10/43 37/62/43 33/58/43
f 34/63/44 138/51/44 30/54/44
f 31/55/45 34/63/45 30/54/45
f 38/64/46 139/65/46 34/63/46
f 35/66/47 38/64/47 34/63/47
f 36/59/48 39/67/48 35/66/48
f 37/60/49 40/68/49 36/59/49
f 21/10/50 41/69/50 37/62/50
f 41/70/51 44/71/51 40/68/51
f 21/10/52 45/72/52 41/69/52
f 42/73/53 152/74/53 38/64/53
f 43/75/54 38/64/54 39/67/54
f 44/71/55 39/67/55 40/68/55
f 46/76/56 150/77/56 42/73/56
f 43/75/57 46/76/57 42/73/57
f 44/71/58 47/78/58 43/75/58
f 49/79/59 44/71/59 45/80/59
f 21/10/60 49/81/60 45/72/60
f 53/82/61 48/83/61 49/84/61
f 21/10/62 53/85/62 49/81/62
f 50/86/63 149/87/63 46/88/63
f 47/89/64 50/86/64 46/88/64
f 48/83/65 51/90/65 47/89/65
f 54/91/66 151/92/66 50/86/66
f 51/90/67 54/91/67 50/86/67
f 56/93/68 51/90/68 52/94/68
f 53/82/69 56/93/69 52/94/69
f 21/10/70 57/95/70 53/85/70
f 21/10/71 61/96/71 57/95/71
f 54/91/72 164/97/72 157/98/72
f 59/99/73 54/91/73 55/100/73
f 60/101/74 55/100/74 56/93/74
f 61/102/75 56/93/75 57/103/75
f 62/104/76 164/97/76 58/105/76
f 63/106/77 58/105/77 59/99/77
f 64/107/78 59/99/78 60/101/78
f 61/102/79 64/107/79 60/101/79
f 21/10/80 65/108/80 61/96/80
f 21/10/81 69/109/81 65/108/81
f 66/110/82 159/111/82 62/104/82
f 67/112/83 62/104/83 63/106/83
f 68/113/84 63/106/84 64/107/84
f 69/114/85 64/107/85 65/115/85
f 71/116/86 66/110/86 67/112/86
f 72/117/87 67/112/87 68/113/87
f 69/114/88 72/117/88 68/113/88
f 21/10/89 73/118/89 69/109/89
f 70/119/90 158/120/90 66/110/90
f 74/121/91 169/122/91 70/119/91
f 71/116/92 74/121/92 70/119/92
f 76/123/93 71/116/93 72/117/93
f 73/124/94 76/123/94 72/117/94
f 21/10/95 77/125/95 73/118/95
f 76/123/96 79/126/96 75/127/96
f 81/128/97 76/123/97 77/129/97
f 21/10/98 81/130/98 77/125/98
f 78/131/99 153/132/99 74/121/99
f 79/126/100 74/121/100 75/127/100
f 82/133/101 144/134/101 78/135/101
f 83/136/102 78/135/102 79/137/102
f 84/138/103 79/137/103 80/139/103
f 81/140/104 84/138/104 80/139/104
f 21/10/105 85/141/105 81/130/105
f 84/138/106 87/142/106 83/136/106
f 89/143/107 84/138/107 85/144/107
f 21/10/108 89/145/108 85/141/108
f 86/146/109 154/147/109 82/133/109
f 87/142/110 82/133/110 83/136/110
f 90/148/111 155/149/111 86/146/111
f 91/150/112 86/146/112 87/142/112
f 92/151/113 87/142/113 88/152/113
f 93/153/114 88/152/114 89/143/114
f 21/10/115 93/154/115 89/145/115
f 97/155/116 92/151/116 93/153/116
f 21/10/117 97/156/117 93/154/117
f 94/157/118 165/158/118 90/148/118
f 95/159/119 90/148/119 91/150/119
f 92/151/120 95/159/120 91/150/120
f 98/160/121 166/161/121 94/157/121
f 99/162/122 94/157/122 95/159/122
f 96/163/123 99/162/123 95/159/123
f 101/164/124 96/163/124 97/155/124
f 21/10/125 101/165/125 97/156/125
f 105/166/126 100/167/126 101/164/126
f 21/10/127 105/168/127 101/165/127
f 102/169/128 162/170/128 98/160/128
f 103/171/129 98/160/129 99/162/129
f 104/172/130 99/162/130 100/167/130
f 106/173/131 168/174/131 102/169/131
f 103/171/132 106/173/132 102/169/132
f 108/175/133 103/171/133 104/172/133
f 109/176/134 104/172/134 105/166/134
f 21/10/135 109/177/135 105/168/135
f 21/10/136 113/178/136 109/177/136
f 110/179/137 148/180/137 106/173/137
f 111/181/138 106/173/138 107/182/138
f 108/175/139 111/181/139 107/182/139
f 113/183/140 108/175/140 109/176/140
f 115/184/141 110/185/141 111/186/141
f 116/187/142 111/186/142 112/188/142
f 117/189/143 112/188/143 113/190/143
f 21/10/144 117/191/144 113/178/144
f 114/192/145 143/193/145 110/185/145
f 118/194/146 156/195/146 114/192/146
f 119/196/147 114/192/147 115/184/147
f 116/187/148 119/196/148 115/184/148
f 121/197/149 116/187/149 117/189/149
f 21/10/150 121/198/150 117/191/150
f 123/199/151 118/194/151 119/196/151
f 124/200/152 119/196/152 120/201/152
f 125/202/153 120/201/153 121/197/153
f 21/10/154 125/203/154 121/198/154
f 122/204/155 147/205/155 118/194/155
f 126/3/156 146/206/156 122/204/156
f 127/5/157 122/204/157 123/199/157
f 128/7/158 123/199/158 124/200/158
f 129/9/159 124/200/159 125/202/159
f 21/10/160 129/12/160 125/203/160
f 131/207/161 132/208/161 130/209/161
f 133/210/162 136/211/162 132/212/162
f 137/213/163 134/214/163 136/215/163
f 135/216/164 130/217/164 134/218/164
f 136/211/165 130/219/165 132/212/165
f 133/220/166 146/221/166 160/222/166
f 159/223/166 158/224/166 131/225/166
f 1/1/1 145/15/1 160/2/1
f 2/4/2 1/1/2 126/3/2
f 3/6/3 2/4/3 127/5/3
f 4/8/4 3/6/4 128/7/4
f 5/14/7 142/19/7 145/15/7
f 2/4/8 6/21/8 5/14/8
f 7/16/9 6/21/9 2/4/9
f 8/17/10 7/16/10 3/6/10
f 9/18/11 141/27/11 142/19/11
f 10/20/12 9/18/12 5/14/12
f 11/22/13 10/20/13 6/21/13
f 12/23/14 11/22/14 7/16/14
f 9/18/17 13/226/17 140/26/17
f 14/28/18 13/226/18 9/18/18
f 15/29/19 14/28/19 10/20/19
f 16/30/20 15/29/20 11/22/20
f 14/31/21 18/42/21 17/32/21
f 19/34/22 18/42/22 14/31/22
f 20/36/23 19/34/23 15/35/23
f 17/32/25 167/41/25 140/39/25
f 17/32/26 22/43/26 161/40/26
f 18/42/27 23/44/27 22/43/27
f 19/34/28 24/45/28 23/44/28
f 20/36/29 25/49/29 24/45/29
f 23/44/31 27/53/31 26/47/31
f 28/48/32 27/53/32 23/44/32
f 25/49/33 29/56/33 28/48/33
f 26/47/35 163/52/35 161/40/35
f 26/47/36 30/54/36 138/51/36
f 27/53/37 31/55/37 30/54/37
f 28/48/38 32/57/38 31/55/38
f 29/56/39 33/61/39 32/57/39
f 36/59/41 35/66/41 31/55/41
f 37/60/42 36/59/42 32/57/42
f 34/63/44 139/65/44 138/51/44
f 31/55/45 35/66/45 34/63/45
f 38/64/46 152/74/46 139/65/46
f 35/66/47 39/67/47 38/64/47
f 36/59/48 40/68/48 39/67/48
f 37/60/49 41/70/49 40/68/49
f 41/70/51 45/80/51 44/71/51
f 42/73/53 150/77/53 152/74/53
f 43/75/54 42/73/54 38/64/54
f 44/71/167 43/75/167 39/67/167
f 46/76/56 149/227/56 150/77/56
f 43/75/57 47/78/57 46/76/57
f 44/71/58 48/228/58 47/78/58
f 49/79/59 48/228/59 44/71/59
f 53/82/61 52/94/61 48/83/61
f 50/86/63 151/92/63 149/87/63
f 47/89/64 51/90/64 50/86/64
f 48/83/65 52/94/65 51/90/65
f 54/91/66 157/98/66 151/92/66
f 51/90/67 55/100/67 54/91/67
f 56/93/68 55/100/68 51/90/68
f 53/82/69 57/103/69 56/93/69
f 54/91/72 58/105/72 164/97/72
f 59/99/73 58/105/73 54/91/73
f 60/101/74 59/99/74 55/100/74
f 61/102/75 60/101/75 56/93/75
f 62/104/76 159/111/76 164/97/76
f 63/106/77 62/104/77 58/105/77
f 64/107/78 63/106/78 59/99/78
f 61/102/79 65/115/79 64/107/79
f 66/110/82 158/120/82 159/111/82
f 67/112/83 66/110/83 62/104/83
f 68/113/84 67/112/84 63/106/84
f 69/114/85 68/113/85 64/107/85
f 71/116/86 70/119/86 66/110/86
f 72/117/87 71/116/87 67/112/87
f 69/114/88 73/124/88 72/117/88
f 70/119/90 169/122/90 158/120/90
f 74/121/91 153/132/91 169/122/91
f 71/116/92 75/127/92 74/121/92
f 76/123/168 75/127/168 71/116/168
f 73/124/94 77/129/94 76/123/94
f 76/123/96 80/229/96 79/126/96
f 81/128/97 80/229/97 76/123/97
f 78/131/99 144/230/99 153/132/99
f 79/126/100 78/131/100 74/121/100
f 82/133/101 154/147/101 144/134/101
f 83/136/102 82/133/102 78/135/102
f 84/138/103 83/136/103 79/137/103
f 81/140/104 85/144/104 84/138/104
f 84/138/106 88/152/106 87/142/106
f 89/143/107 88/152/107 84/138/107
f 86/146/109 155/149/109 154/147/109
f 87/142/110 86/146/110 82/133/110
f 90/148/111 165/158/111 155/149/111
f 91/150/112 90/148/112 86/146/112
f 92/151/113 91/150/113 87/142/113
f 93/153/114 92/151/114 88/152/114
f 97/155/116 96/163/116 92/151/116
f 94/157/118 166/161/118 165/158/118
f 95/159/119 94/157/119 90/148/119
f 92/151/120 96/163/120 95/159/120
f 98/160/121 162/170/121 166/161/121
f 99/162/122 98/160/122 94/157/122
f 96/163/123 100/167/123 99/162/123
f 101/164/124 100/167/124 96/163/124
f 105/166/126 104/172/126 100/167/126
f 102/169/128 168/174/128 162/170/128
f 103/171/129 102/169/129 98/160/129
f 104/172/130 103/171/130 99/162/130
f 106/173/131 148/180/131 168/174/131
f 103/171/132 107/182/132 106/173/132
f 108/175/133 107/182/133 103/171/133
f 109/176/134 108/175/134 104/172/134
f 110/179/137 143/231/137 148/180/137
f 111/181/138 110/179/138 106/173/138
f 108/175/139 112/232/139 111/181/139
f 113/183/140 112/232/140 108/175/140
f 115/184/141 114/192/141 110/185/141
f 116/187/142 115/184/142 111/186/142
f 117/189/143 116/187/143 112/188/143
f 114/192/145 156/195/145 143/193/145
f 118/194/146 147/205/146 156/195/146
f 119/196/147 118/194/147 114/192/147
f 116/187/169 120/201/169 119/196/169
f 121/197/149 120/201/149 116/187/149
f 123/199/151 122/204/151 118/194/151
f 124/200/152 123/199/152 119/196/152
f 125/202/153 124/200/153 120/201/153
f 122/204/155 146/206/155 147/205/155
f 126/3/156 160/2/156 146/206/156
f 127/5/157 126/3/157 122/204/157
f 128/7/158 127/5/158 123/199/158
f 129/9/159 128/7/159 124/200/159
f 131/207/161 133/233/161 132/208/161
f 133/210/162 137/234/162 136/211/162
f 137/213/163 135/235/163 134/214/163
f 135/216/164 131/236/164 130/217/164
f 136/211/165 134/237/165 130/219/165
f 133/220/166 131/238/166 166/239/166
f 133/220/166 166/239/166 162/240/166
f 138/241/166 135/242/166 137/243/166
f 163/244/166 138/241/166 137/243/166
f 133/220/166 162/240/166 168/245/166
f 133/220/166 168/245/166 148/246/166
f 161/247/166 163/244/166 137/243/166
f 167/248/166 161/247/166 137/243/166
f 133/220/166 148/246/166 143/249/166
f 133/220/166 143/249/166 156/250/166
f 140/251/166 167/248/166 137/243/166
f 141/252/166 140/251/166 137/243/166
f 137/243/166 133/220/166 160/222/166
f 133/220/166 156/250/166 147/253/166
f 142/254/166 141/252/166 137/243/166
f 145/255/166 142/254/166 137/243/166
f 133/220/166 147/253/166 146/221/166
f 160/222/166 145/255/166 137/243/166
f 135/256/166 138/257/166 139/258/166
f 135/256/166 139/258/166 152/259/166
f 165/260/166 166/261/166 131/225/166
f 155/262/166 165/260/166 131/225/166
f 135/256/166 152/259/166 150/263/166
f 135/256/166 150/263/166 149/264/166
f 154/265/166 155/262/166 131/225/166
f 144/266/166 154/265/166 131/225/166
f 135/256/166 149/264/166 151/267/166
f 135/256/166 151/267/166 157/268/166
f 153/269/166 144/266/166 131/225/166
f 169/270/166 153/269/166 131/225/166
f 131/225/166 135/256/166 159/223/166
f 135/256/166 157/268/166 164/271/166
f 158/224/166 169/270/166 131/225/166
f 135/256/166 164/271/166 159/223/166

View File

@@ -0,0 +1,30 @@
<?xml version="0.0" ?>
<robot name="urdf_robot">
<link name="base_link">
<contact>
<rolling_friction value="0.001"/>
<spinning_friction value="0.001"/>
</contact>
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value="0"/>
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
</inertial>
<visual>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<mesh filename="concave_box.obj" scale="1 1 1"/>
</geometry>
<material name="white">
<color rgba="1 1 1 1"/>
</material>
</visual>
<collision>
<origin rpy="0 0 0" xyz="0 0 0"/>
<geometry>
<cdf filename="concave_box.cdf" scale="1 1 1"/>
</geometry>
</collision>
</link>
</robot>

11
data/toys/cube.mtl Normal file
View File

@@ -0,0 +1,11 @@
# Blender MTL File: 'shape_sort.blend'
# Material Count: 1
newmtl Material.002
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.017444 0.640000 0.032216
Ks 0.034126 0.500000 0.031333
Ni 1.000000
d 1.000000
illum 2

64
data/toys/cube.obj Normal file
View File

@@ -0,0 +1,64 @@
# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend'
# www.blender.org
mtllib cube.mtl
o Cube.001_Cube.002
v -0.231854 0.040516 -0.056463
v -0.231854 0.040516 -0.121937
v -0.144556 0.040516 -0.121937
v -0.144556 0.040516 -0.056463
v -0.231854 0.127815 -0.056463
v -0.231854 0.127815 -0.121937
v -0.144556 0.127815 -0.121937
v -0.144556 0.127815 -0.056463
v -0.231854 0.040516 -0.056463
v -0.231854 0.040516 -0.121937
v -0.144556 0.040516 -0.121937
v -0.144556 0.040516 -0.056463
v -0.231854 0.127815 -0.056463
v -0.231854 0.127815 -0.121937
v -0.144556 0.127815 -0.121937
v -0.144556 0.127815 -0.056463
vt 1.044600 0.042083
vt 1.044600 -0.957917
vt 0.044600 -0.957917
vt 1.905897 0.042083
vt 1.905897 -0.957917
vt 0.905898 -0.957917
vt -0.955400 0.042083
vt -0.955400 -0.957917
vt -0.094102 0.042083
vt -0.094102 -0.957917
vt 0.905898 1.044600
vt 1.905897 1.044600
vt 1.905897 0.044600
vt -0.094102 1.044600
vt -0.094102 0.044600
vt 0.044600 0.042083
vt 0.905898 0.042083
vt 0.905898 0.044600
usemtl Material.002
s off
f 6/1 2/2 1/3
f 7/4 3/5 2/6
f 8/7 4/8 3/3
f 5/9 1/10 4/6
f 2/11 3/12 4/13
f 7/11 6/14 5/15
f 14/1 10/2 9/3
f 15/4 11/5 10/6
f 16/7 12/8 11/3
f 13/9 9/10 12/6
f 10/11 11/12 12/13
f 15/11 14/14 13/15
f 5/16 6/1 1/3
f 6/17 7/4 2/6
f 7/16 8/7 3/3
f 8/17 5/9 4/6
f 1/18 2/11 4/13
f 8/18 7/11 5/15
f 13/16 14/1 9/3
f 14/17 15/4 10/6
f 15/16 16/7 11/3
f 16/17 13/9 12/6
f 9/18 10/11 12/13
f 16/18 15/11 13/15

11
data/toys/cylinder.mtl Normal file
View File

@@ -0,0 +1,11 @@
# Blender MTL File: 'shape_sort.blend'
# Material Count: 1
newmtl Material.001
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.013473 0.018536 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

282
data/toys/cylinder.obj Normal file
View File

@@ -0,0 +1,282 @@
# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend'
# www.blender.org
mtllib cylinder.mtl
o Cylinder.001
v -0.291246 0.045696 0.165546
v -0.214241 0.045696 0.165546
v -0.291246 0.034429 0.166100
v -0.214241 0.034429 0.166100
v -0.291246 0.023595 0.167744
v -0.214241 0.023595 0.167744
v -0.291246 0.013610 0.170412
v -0.214241 0.013610 0.170412
v -0.291246 0.004859 0.174003
v -0.214241 0.004858 0.174003
v -0.291246 -0.002324 0.178379
v -0.214241 -0.002324 0.178379
v -0.291246 -0.007661 0.183372
v -0.214241 -0.007661 0.183372
v -0.291246 -0.010947 0.188789
v -0.214241 -0.010947 0.188789
v -0.291246 -0.012057 0.194422
v -0.214241 -0.012057 0.194422
v -0.291246 -0.010947 0.200056
v -0.214241 -0.010947 0.200056
v -0.291246 -0.007661 0.205473
v -0.214241 -0.007661 0.205473
v -0.291246 -0.002324 0.210465
v -0.214241 -0.002324 0.210465
v -0.291246 0.004859 0.214841
v -0.214241 0.004858 0.214841
v -0.291246 0.013610 0.218432
v -0.214241 0.013610 0.218432
v -0.291246 0.023595 0.221101
v -0.214241 0.023595 0.221101
v -0.291246 0.034429 0.222744
v -0.214241 0.034429 0.222744
v -0.291246 0.045696 0.223299
v -0.214241 0.045696 0.223299
v -0.291246 0.056963 0.222744
v -0.214241 0.056963 0.222744
v -0.291246 0.067797 0.221101
v -0.214241 0.067797 0.221101
v -0.291246 0.077782 0.218432
v -0.214241 0.077782 0.218432
v -0.291246 0.086534 0.214841
v -0.214241 0.086534 0.214841
v -0.291246 0.093716 0.210465
v -0.214241 0.093716 0.210465
v -0.291246 0.099053 0.205473
v -0.214241 0.099053 0.205473
v -0.291246 0.102340 0.200056
v -0.214241 0.102340 0.200056
v -0.291246 0.103449 0.194422
v -0.214241 0.103449 0.194422
v -0.291246 0.102340 0.188789
v -0.214241 0.102340 0.188789
v -0.291246 0.099053 0.183371
v -0.214241 0.099053 0.183371
v -0.291246 0.093716 0.178379
v -0.214241 0.093716 0.178379
v -0.291246 0.086534 0.174003
v -0.214241 0.086534 0.174003
v -0.291246 0.077782 0.170412
v -0.214241 0.077782 0.170412
v -0.291246 0.067797 0.167744
v -0.214241 0.067797 0.167744
v -0.291246 0.056963 0.166100
v -0.214241 0.056963 0.166100
vt 0.306049 0.488177
vt 0.092448 0.519423
vt 0.067655 0.516411
vt 0.270128 0.485165
vt 0.049219 0.513369
vt 0.232794 0.482123
vt 0.034123 0.510414
vt 0.020864 0.507658
vt 0.163092 0.476412
vt 0.008587 0.505209
vt 0.133302 0.473963
vt 1.008587 0.505209
vt 0.996728 0.503160
vt 1.106812 0.471914
vt 0.984865 0.501590
vt 1.082707 0.470344
vt 0.972628 0.500559
vt 0.959652 0.500107
vt 1.036012 0.468861
vt 0.945535 0.500252
vt 1.008811 0.469006
vt 0.929810 0.500987
vt 0.972352 0.469741
vt 0.911918 0.502285
vt 0.913273 0.471038
vt 0.891203 0.504095
vt 0.866959 0.506348
vt 0.698338 0.475102
vt 0.838607 0.508958
vt 0.630535 0.477711
vt 0.806049 0.511823
vt 0.592448 0.480577
vt 0.770128 0.514835
vt 0.732794 0.517877
vt 0.549219 0.486631
vt 0.696491 0.520833
vt 0.534123 0.489586
vt 0.663092 0.523588
vt 0.520864 0.492342
vt 0.633302 0.526037
vt 0.508586 0.494791
vt 0.606812 0.528086
vt 0.496728 0.496840
vt 0.582707 0.529656
vt 0.559695 0.530687
vt 0.472628 0.499441
vt 0.536012 0.531139
vt 0.459652 0.499893
vt 0.508810 0.530994
vt 0.445535 0.499748
vt 0.472352 0.530259
vt 0.413273 0.528962
vt 0.411918 0.497715
vt 0.310810 0.527152
vt 0.391202 0.495905
vt 0.198337 0.524898
vt 1.020864 0.507658
vt 1.034123 0.510414
vt 0.130535 0.522289
vt 0.366959 0.493652
vt 1.391202 0.495905
vt 0.196491 0.479167
vt 1.133302 0.473963
vt 1.059695 0.469313
vt 0.810811 0.472848
vt 0.567655 0.483589
vt 0.484865 0.498410
vt 0.429810 0.499013
vt 1.092448 0.519423
vt 1.067655 0.516411
vt 1.198337 0.524898
vt 1.413273 0.528962
vt 1.310810 0.527152
vt 1.472352 0.530259
vt 1.130535 0.522289
vt 1.049219 0.513369
vt 0.338607 0.491042
vt 1.270128 0.485165
vt 1.306049 0.488177
vt 1.196491 0.479167
vt 1.232794 0.482123
vt 1.163092 0.476412
vt 1.366959 0.493652
vt 1.338607 0.491042
vt 1.429810 0.499013
vt 1.411918 0.497715
vt 1.445535 0.499748
vt 1.459652 0.499893
usemtl Material.001
s off
f 1/1 2/2 4/3
f 3/4 4/3 6/5
f 5/6 6/5 8/7
f 8/7 10/8 9/9
f 10/8 12/10 11/11
f 12/12 14/13 13/14
f 14/13 16/15 15/16
f 15/16 16/15 18/17
f 18/17 20/18 19/19
f 20/18 22/20 21/21
f 22/20 24/22 23/23
f 24/22 26/24 25/25
f 25/25 26/24 28/26
f 28/26 30/27 29/28
f 30/27 32/29 31/30
f 32/29 34/31 33/32
f 33/32 34/31 36/33
f 36/33 38/34 37/35
f 38/34 40/36 39/37
f 40/36 42/38 41/39
f 42/38 44/40 43/41
f 44/40 46/42 45/43
f 45/43 46/42 48/44
f 48/44 50/45 49/46
f 50/45 52/47 51/48
f 52/47 54/49 53/50
f 53/50 54/49 56/51
f 56/51 58/52 57/53
f 58/52 60/54 59/55
f 59/55 60/54 62/56
f 26/24 10/57 8/58
f 64/59 2/2 1/1
f 61/60 62/56 64/59
f 37/35 39/37 59/61
f 3/4 1/1 4/3
f 5/6 3/4 6/5
f 7/62 5/6 8/7
f 7/62 8/7 9/9
f 9/9 10/8 11/11
f 11/63 12/12 13/14
f 13/14 14/13 15/16
f 17/64 15/16 18/17
f 17/64 18/17 19/19
f 19/19 20/18 21/21
f 21/21 22/20 23/23
f 23/23 24/22 25/25
f 27/65 25/25 28/26
f 27/65 28/26 29/28
f 29/28 30/27 31/30
f 31/30 32/29 33/32
f 35/66 33/32 36/33
f 35/66 36/33 37/35
f 37/35 38/34 39/37
f 39/37 40/36 41/39
f 41/39 42/38 43/41
f 43/41 44/40 45/43
f 47/67 45/43 48/44
f 47/67 48/44 49/46
f 49/46 50/45 51/48
f 51/48 52/47 53/50
f 55/68 53/50 56/51
f 55/68 56/51 57/53
f 57/53 58/52 59/55
f 61/60 59/55 62/56
f 2/69 34/31 4/70
f 38/34 36/33 62/71
f 58/72 40/36 60/73
f 54/49 44/40 56/74
f 50/45 48/44 52/47
f 46/42 54/49 48/44
f 14/13 22/20 20/18
f 12/12 10/57 24/22
f 2/69 64/75 34/31
f 30/27 6/76 32/29
f 26/24 8/58 28/26
f 63/77 61/60 64/59
f 64/75 36/33 34/31
f 14/13 20/18 16/15
f 44/40 42/38 56/74
f 40/36 38/34 60/73
f 38/34 62/71 60/73
f 10/57 26/24 24/22
f 48/44 54/49 52/47
f 34/31 32/29 4/70
f 8/58 6/76 28/26
f 54/49 46/42 44/40
f 20/18 18/17 16/15
f 42/38 58/72 56/74
f 63/77 64/59 1/1
f 32/29 6/76 4/70
f 12/12 24/22 14/13
f 58/72 42/38 40/36
f 36/33 64/75 62/71
f 24/22 22/20 14/13
f 6/76 30/27 28/26
f 3/78 31/30 1/79
f 7/80 29/28 5/81
f 11/63 23/23 9/82
f 15/16 21/21 13/14
f 15/16 17/64 19/19
f 61/83 63/84 35/66
f 27/65 7/80 25/25
f 41/39 55/85 57/86
f 35/66 63/84 33/32
f 53/87 55/85 43/41
f 43/41 55/85 41/39
f 47/67 53/87 45/43
f 47/67 49/46 51/88
f 59/61 39/37 57/86
f 29/28 31/30 5/81
f 7/80 27/65 29/28
f 45/43 53/87 43/41
f 47/67 51/88 53/87
f 61/83 37/35 59/61
f 31/30 3/78 5/81
f 15/16 19/19 21/21
f 21/21 23/23 13/14
f 39/37 41/39 57/86
f 7/80 9/82 25/25
f 1/79 31/30 33/32
f 23/23 11/63 13/14
f 9/82 23/23 25/25
f 37/35 61/83 35/66
f 63/84 1/79 33/32

11
data/toys/prism.mtl Normal file
View File

@@ -0,0 +1,11 @@
# Blender MTL File: 'shape_sort.blend'
# Material Count: 1
newmtl Material.003
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.007339 0.006282
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

45
data/toys/prism.obj Normal file
View File

@@ -0,0 +1,45 @@
# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend'
# www.blender.org
mtllib prism.mtl
o Cube.002_Cube.005
v -0.233641 -0.103557 0.060897
v -0.233641 -0.103557 -0.057063
v -0.149383 -0.103557 -0.057063
v -0.149383 -0.103557 0.060897
v -0.233013 -0.039217 0.035115
v -0.233013 -0.039217 -0.031280
v -0.150011 -0.039217 -0.031280
v -0.150011 -0.039217 0.035115
vt 0.780473 0.523151
vt 0.999041 -0.022288
vt -0.000959 -0.022288
vt 1.896793 0.523151
vt 1.904244 -0.022288
vt 0.904244 -0.022288
vt 0.217610 0.523151
vt -0.088305 0.523151
vt -0.095756 -0.022288
vt 0.904244 1.999041
vt 1.904244 1.999041
vt 1.904244 0.999041
vt 0.896793 0.780473
vt -0.088305 0.780473
vt -0.088305 0.217610
vt 0.911695 0.523151
vt 0.896793 0.523151
vt 0.904244 0.999041
vt 0.896793 0.217610
usemtl Material.003
s off
f 6/1 2/2 1/3
f 7/4 3/5 2/6
f 8/7 4/3 3/2
f 5/8 1/9 4/6
f 2/10 3/11 4/12
f 7/13 6/14 5/15
f 5/7 6/1 1/3
f 6/16 7/4 2/6
f 7/1 8/7 3/2
f 8/17 5/8 4/6
f 1/18 2/10 4/12
f 8/19 7/13 5/15

View File

@@ -0,0 +1,21 @@
# Blender MTL File: 'shape_sort.blend'
# Material Count: 2
newmtl Material.004
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2
map_Kd E:\develop\bullet3\data\table\table.png
newmtl Material.004_NONE
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 0.640000 0.640000 0.640000
Ks 0.500000 0.500000 0.500000
Ni 1.000000
d 1.000000
illum 2

400
data/toys/shape_sorter.obj Normal file
View File

@@ -0,0 +1,400 @@
# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend'
# www.blender.org
mtllib shape_sorter.mtl
o Cube
v -0.200000 0.200000 -0.200000
v -0.200000 -0.200000 -0.200000
v -0.200000 0.037707 -0.055248
v -0.200000 0.037707 -0.124929
v -0.200000 0.130615 -0.124929
v -0.200000 0.130615 -0.055248
v -0.200000 -0.200000 0.200000
v -0.200000 0.014752 0.076444
v -0.200000 -0.109627 0.071917
v -0.200000 -0.109627 -0.068083
v -0.200000 -0.033266 -0.037483
v -0.200000 -0.033266 0.041318
v -0.200000 0.015905 0.070592
v -0.200000 0.019320 0.064964
v -0.200000 0.024864 0.059777
v -0.200000 0.032326 0.055231
v -0.200000 0.041418 0.051500
v -0.200000 0.051791 0.048728
v -0.200000 0.063047 0.047021
v -0.200000 0.074753 0.046444
v -0.200000 0.086458 0.047021
v -0.200000 0.097713 0.048728
v -0.200000 0.108087 0.051500
v -0.200000 0.117179 0.055231
v -0.200000 0.124641 0.059777
v -0.200000 0.130185 0.064964
v -0.200000 0.133600 0.070592
v -0.200000 0.200000 0.200000
v 0.200000 0.200000 -0.200000
v 0.200000 -0.200000 -0.200000
v -0.179938 0.037707 -0.055248
v -0.179938 0.037707 -0.124929
v -0.179938 0.130615 -0.124929
v -0.179938 0.130615 -0.055248
v -0.179938 0.200000 0.179938
v -0.179938 0.200000 -0.179938
v 0.179938 0.200000 -0.179938
v 0.200000 -0.200000 0.200000
v -0.200000 0.134752 0.076444
v -0.200000 0.133600 0.082297
v -0.200000 0.130185 0.087925
v -0.200000 0.124641 0.093111
v -0.200000 0.117179 0.097657
v -0.200000 0.108087 0.101388
v -0.200000 0.097714 0.104161
v -0.200000 0.086458 0.105868
v -0.200000 0.074753 0.106444
v -0.200000 0.063047 0.105868
v -0.200000 0.051792 0.104161
v -0.200000 0.041418 0.101388
v -0.200000 0.032326 0.097657
v -0.200000 0.024864 0.093111
v -0.200000 0.019320 0.087925
v -0.200000 0.015905 0.082297
v -0.179938 0.014752 0.076444
v -0.179938 0.015905 0.070592
v -0.179938 0.019320 0.064964
v -0.179938 0.024864 0.059777
v -0.179938 0.032326 0.055231
v -0.179938 0.041418 0.051500
v -0.179938 0.051791 0.048728
v -0.179938 0.063047 0.047021
v -0.179938 0.074752 0.046444
v -0.179938 0.086458 0.047021
v -0.179938 0.097713 0.048728
v -0.179938 0.108087 0.051500
v -0.179938 0.117179 0.055231
v -0.179938 0.124641 0.059777
v -0.179938 0.130185 0.064964
v -0.179938 0.133600 0.070592
v 0.200000 0.200000 0.200000
v -0.179938 -0.185168 -0.179938
v 0.179938 0.200000 0.179938
v -0.179938 -0.185168 0.179938
v -0.179938 0.015905 0.082297
v -0.179938 0.019320 0.087925
v -0.179938 0.024864 0.093111
v -0.179938 0.032326 0.097657
v -0.179938 0.041418 0.101388
v -0.179938 0.051791 0.104161
v -0.179938 0.063047 0.105868
v -0.179938 0.074753 0.106444
v -0.179938 0.086458 0.105868
v -0.179938 0.097714 0.104161
v -0.179938 0.108087 0.101388
v -0.179938 0.117179 0.097657
v -0.179938 0.124641 0.093111
v -0.179938 0.130185 0.087925
v -0.179938 0.133600 0.082297
v -0.179938 0.134752 0.076444
v 0.179938 -0.185168 -0.179938
v -0.179938 -0.109627 0.071917
v -0.179938 -0.033266 0.041318
v -0.179938 -0.033266 -0.037483
v -0.179938 -0.109627 -0.068083
v 0.179938 -0.185168 0.179938
vt 0.337529 0.596545
vt 0.387821 0.596545
vt 0.283346 0.663317
vt 0.379674 0.386434
vt 0.283346 0.278382
vt 0.572047 0.278383
vt 0.387821 0.507137
vt 0.461218 0.542787
vt 0.461634 0.554051
vt 0.372847 0.595850
vt 0.372847 0.369934
vt 0.391646 0.506894
vt 0.343069 0.506894
vt 0.337529 0.507137
vt 0.343069 0.593253
vt 0.391646 0.593253
vt 0.304720 0.657748
vt 0.378834 0.597878
vt 0.542284 0.369934
vt 0.572047 0.663317
vt 0.504523 0.542787
vt 0.504107 0.531523
vt 0.482871 0.485047
vt 0.483455 0.485557
vt 0.479374 0.486628
vt 0.478646 0.486156
vt 0.475451 0.489802
vt 0.474584 0.489442
vt 0.471835 0.494956
vt 0.467560 0.501959
vt 0.470841 0.494778
vt 0.468666 0.501892
vt 0.466065 0.510343
vt 0.462866 0.520691
vt 0.464867 0.510708
vt 0.461634 0.531522
vt 0.464132 0.519985
vt 0.462942 0.530448
vt 0.462540 0.541328
vt 0.462942 0.552208
vt 0.462866 0.564883
vt 0.464132 0.562671
vt 0.466065 0.572313
vt 0.467560 0.583615
vt 0.464867 0.574866
vt 0.468666 0.580764
vt 0.471835 0.587700
vt 0.474584 0.596132
vt 0.470841 0.590796
vt 0.475451 0.592854
vt 0.479374 0.596028
vt 0.542284 0.595850
vt 0.304720 0.299726
vt 0.555605 0.657748
vt 0.504369 0.541328
vt 0.503967 0.552209
vt 0.378834 0.375736
vt 0.383150 0.371876
vt 0.555605 0.299726
vt 0.478646 0.599418
vt 0.483455 0.597099
vt 0.482870 0.600527
vt 0.487535 0.596028
vt 0.487095 0.599418
vt 0.491458 0.592854
vt 0.491157 0.596132
vt 0.495074 0.587700
vt 0.494900 0.590796
vt 0.498243 0.580764
vt 0.498181 0.583615
vt 0.500844 0.572313
vt 0.502875 0.564883
vt 0.500874 0.574866
vt 0.502777 0.562671
vt 0.504107 0.554052
vt 0.503967 0.530448
vt 0.502777 0.519985
vt 0.502875 0.520691
vt 0.500844 0.510343
vt 0.500874 0.510708
vt 0.498243 0.501892
vt 0.498181 0.501959
vt 0.495074 0.494956
vt 0.494900 0.494778
vt 0.491458 0.489802
vt 0.491157 0.489442
vt 0.487535 0.486628
vt 0.487095 0.486156
vt 0.534501 0.375736
vt 0.534501 0.597878
vt 0.478009 0.388189
vt 0.400119 0.458779
vt 0.457642 0.460616
vt 0.480077 0.374691
vt 0.459415 0.445604
vt 0.404578 0.442049
vt 0.000000 0.000000
usemtl Material.004
s off
f 5/1 6/2 1/3
f 10/4 2/5 7/6
f 3/7 20/8 21/9
f 29/10 30/11 2/5
f 3/7 31/12 32/13
f 4/14 32/13 33/15
f 34/16 6/2 5/1
f 36/17 37/18 29/10
f 31/12 3/7 6/2
f 2/5 30/11 38/19
f 28/20 47/21 48/22
f 8/23 55/24 56/25
f 13/26 56/25 57/27
f 14/28 57/27 58/29
f 16/30 15/31 58/29
f 16/30 59/32 60/33
f 18/34 17/35 60/33
f 19/36 18/34 61/37
f 20/8 19/36 62/38
f 20/8 63/39 64/40
f 22/41 21/9 64/40
f 22/41 65/42 66/43
f 24/44 23/45 66/43
f 24/44 67/46 68/47
f 26/48 25/49 68/47
f 26/48 69/50 70/51
f 71/52 38/19 30/11
f 32/13 31/12 72/53
f 71/52 29/10 37/18
f 35/54 82/55 83/56
f 36/17 72/53 91/57
f 62/38 61/37 31/12
f 95/58 74/59 72/53
f 28/20 7/6 38/19
f 27/60 70/51 90/61
f 39/62 90/61 89/63
f 40/64 89/63 88/65
f 41/66 88/65 87/67
f 42/68 87/67 86/69
f 43/70 86/69 85/71
f 45/72 44/73 85/71
f 45/72 84/74 83/56
f 46/75 83/56 82/55
f 47/21 82/55 81/76
f 48/22 81/76 80/77
f 49/78 80/77 79/79
f 50/80 79/79 78/81
f 51/82 78/81 77/83
f 52/84 77/83 76/85
f 53/86 76/85 75/87
f 54/88 75/87 55/24
f 37/18 91/57 96/89
f 73/90 96/89 74/59
f 74/59 96/89 91/57
f 2/5 3/7 4/14
f 7/6 8/23 9/91
f 1/3 2/5 4/14
f 1/3 4/14 5/1
f 10/4 11/92 3/7
f 9/91 10/4 7/6
f 10/4 3/7 2/5
f 12/93 16/30 11/92
f 28/20 1/3 6/2
f 12/93 9/91 8/23
f 27/60 28/20 6/2
f 14/28 15/31 12/93
f 12/93 8/23 13/26
f 26/48 27/60 6/2
f 12/93 13/26 14/28
f 25/49 26/48 6/2
f 1/3 29/10 2/5
f 24/44 25/49 6/2
f 3/7 16/30 17/35
f 23/45 24/44 6/2
f 3/7 17/35 18/34
f 22/41 23/45 6/2
f 3/7 18/34 19/36
f 21/9 22/41 6/2
f 16/30 3/7 11/92
f 6/2 3/7 21/9
f 12/93 15/31 16/30
f 4/14 3/7 32/13
f 3/7 19/36 20/8
f 5/1 4/14 33/15
f 33/15 34/16 5/1
f 1/3 28/20 35/54
f 34/16 31/12 6/2
f 1/3 35/54 36/17
f 36/17 29/10 1/3
f 7/6 2/5 38/19
f 28/20 27/60 39/62
f 54/88 8/23 7/6
f 28/20 39/62 40/64
f 53/86 54/88 7/6
f 28/20 40/64 41/66
f 52/84 53/86 7/6
f 28/20 41/66 42/68
f 51/82 52/84 7/6
f 28/20 42/68 43/70
f 50/80 51/82 7/6
f 28/20 43/70 44/73
f 49/78 50/80 7/6
f 44/73 45/72 28/20
f 7/6 28/20 49/78
f 28/20 45/72 46/75
f 14/28 13/26 57/27
f 13/26 8/23 56/25
f 28/20 48/22 49/78
f 28/20 46/75 47/21
f 15/31 14/28 58/29
f 59/32 16/30 58/29
f 17/35 16/30 60/33
f 61/37 18/34 60/33
f 62/38 19/36 61/37
f 63/39 20/8 62/38
f 21/9 20/8 64/40
f 65/42 22/41 64/40
f 23/45 22/41 66/43
f 67/46 24/44 66/43
f 25/49 24/44 68/47
f 69/50 26/48 68/47
f 27/60 26/48 70/51
f 29/10 71/52 30/11
f 36/17 34/16 33/15
f 35/54 28/20 71/52
f 33/15 32/13 36/17
f 74/59 55/24 75/87
f 32/13 72/53 36/17
f 73/90 35/54 71/52
f 71/52 37/18 73/90
f 36/17 35/54 34/16
f 74/59 75/87 76/85
f 31/12 63/39 62/38
f 74/59 76/85 77/83
f 35/54 90/61 34/16
f 74/59 77/83 78/81
f 88/65 89/63 35/54
f 78/81 79/79 74/59
f 87/67 88/65 35/54
f 74/59 79/79 80/77
f 86/69 87/67 35/54
f 35/54 74/59 80/77
f 85/71 86/69 35/54
f 35/54 80/77 81/76
f 84/74 85/71 35/54
f 35/54 81/76 82/55
f 83/56 84/74 35/54
f 37/18 36/17 91/57
f 35/54 89/63 90/61
f 34/16 90/61 70/51
f 92/94 93/95 55/24
f 92/94 55/24 74/59
f 34/16 70/51 69/50
f 59/32 94/96 31/12
f 34/16 69/50 68/47
f 31/12 34/16 64/40
f 34/16 68/47 67/46
f 93/95 57/27 56/25
f 34/16 67/46 66/43
f 93/95 58/29 57/27
f 34/16 66/43 65/42
f 93/95 59/32 58/29
f 34/16 65/42 64/40
f 93/95 94/96 59/32
f 63/39 31/12 64/40
f 61/37 60/33 31/12
f 93/95 56/25 55/24
f 94/96 95/58 31/12
f 60/33 59/32 31/12
f 39/62 27/60 90/61
f 95/58 92/94 74/59
f 71/52 28/20 38/19
f 95/58 72/53 31/12
f 40/64 39/62 89/63
f 41/66 40/64 88/65
f 42/68 41/66 87/67
f 43/70 42/68 86/69
f 44/73 43/70 85/71
f 84/74 45/72 85/71
f 46/75 45/72 83/56
f 47/21 46/75 82/55
f 48/22 47/21 81/76
f 49/78 48/22 80/77
f 50/80 49/78 79/79
f 51/82 50/80 78/81
f 52/84 51/82 77/83
f 53/86 52/84 76/85
f 54/88 53/86 75/87
f 8/23 54/88 55/24
f 73/90 37/18 96/89
f 35/54 73/90 74/59
f 72/53 74/59 91/57
usemtl Material.004_NONE
f 10/97 95/97 94/97
f 93/97 12/97 11/97
f 10/97 9/97 92/97
f 92/97 9/97 12/97
f 11/97 10/97 94/97
f 94/97 93/97 11/97
f 95/97 10/97 92/97
f 93/97 92/97 12/97

View File

@@ -94,8 +94,8 @@ struct GUIHelperInterface
int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels,
int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied){}
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])=0;
virtual void setProjectiveTexture(bool useProjectiveTexture)=0;
virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){}
virtual void setProjectiveTexture(bool useProjectiveTexture){}
virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0;

View File

@@ -16,6 +16,7 @@ enum
B3_CREATE_SHADOWMAP_RENDERMODE,
B3_USE_SHADOWMAP_RENDERMODE,
B3_USE_SHADOWMAP_RENDERMODE_REFLECTION,
B3_USE_SHADOWMAP_RENDERMODE_REFLECTION_PLANE,
B3_USE_PROJECTIVE_TEXTURE_RENDERMODE,
};
@@ -77,6 +78,8 @@ struct CommonRenderInterface
virtual void replaceTexture(int shapeIndex, int textureIndex){};
virtual void removeTexture(int textureIndex) = 0;
virtual void setPlaneReflectionShapeIndex(int index) {}
virtual int getShapeIndexFromInstance(int srcIndex) {return -1;}
virtual bool readSingleInstanceTransformToCPU(float* position, float* orientation, int srcIndex)=0;

View File

@@ -356,7 +356,7 @@ void AllConstraintDemo::initPhysics()
spSlider6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
spSlider6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = -5.0f;
spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f;
m_dynamicsWorld->addConstraint(spSlider6Dof);
@@ -431,7 +431,7 @@ void AllConstraintDemo::initPhysics()
// pGen6DOF->getTranslationalLimitMotor()->m_enableMotor[0] = true;
// pGen6DOF->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f;
// pGen6DOF->setAngularLowerLimit(btVector3(0., SIMD_HALF_PI*0.9, 0.));
@@ -662,7 +662,7 @@ void AllConstraintDemo::initPhysics()
pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true;
pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f;
pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f;
pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f;
}
#endif

View File

@@ -300,11 +300,11 @@ void Dof6Spring2Setup::initPhysics()
#ifdef USE_6DOF2
constraint->enableMotor(5,true);
constraint->setTargetVelocity(5,3.f);
constraint->setMaxMotorForce(5,10.f);
constraint->setMaxMotorForce(5,600.f);
#else
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
#endif
constraint->setDbgDrawSize(btScalar(2.f));
m_dynamicsWorld->addConstraint(constraint, true);
@@ -335,13 +335,13 @@ void Dof6Spring2Setup::initPhysics()
#ifdef USE_6DOF2
constraint->enableMotor(5,true);
constraint->setTargetVelocity(5,3.f);
constraint->setMaxMotorForce(5,10.f);
constraint->setMaxMotorForce(5,600.f);
constraint->setServo(5,true);
constraint->setServoTarget(5, M_PI_2);
#else
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
//servo motor is not implemented in 6dofspring constraint
#endif
constraint->setDbgDrawSize(btScalar(2.f));

View File

@@ -226,7 +226,6 @@ SET(BulletExampleBrowser_SRCS
../MultiThreading/b3PosixThreadSupport.cpp
../MultiThreading/b3Win32ThreadSupport.cpp
../MultiThreading/b3ThreadSupportInterface.cpp
../MultiThreading/btTaskScheduler.cpp
../RenderingExamples/TinyRendererSetup.cpp
../RenderingExamples/TimeSeriesCanvas.cpp
../RenderingExamples/TimeSeriesCanvas.h
@@ -339,15 +338,8 @@ SET(BulletExampleBrowser_SRCS
../ThirdPartyLibs/stb_image/stb_image.h
../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../ThirdPartyLibs/tinyxml/tinystr.cpp
../ThirdPartyLibs/tinyxml/tinyxml.cpp
../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
../ThirdPartyLibs/tinyxml/tinystr.cpp
../ThirdPartyLibs/tinyxml/tinyxml.cpp
../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
../ThirdPartyLibs/tinyxml2/tinyxml2.cpp
InProcessExampleBrowser.cpp
${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc
)

View File

@@ -185,7 +185,13 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans
}
} else
{
btAssert(0);
if (collisionShape->getShapeType()==SDF_SHAPE_PROXYTYPE)
{
//not yet
} else
{
btAssert(0);
}
}
}

View File

@@ -18,6 +18,8 @@
void ExampleBrowserThreadFunc(void* userPtr,void* lsMemory);
void* ExampleBrowserMemoryFunc();
void ExampleBrowserMemoryReleaseFunc(void* ptr);
#include <stdio.h>
//#include "BulletMultiThreaded/PlatformDefinitions.h"
@@ -42,6 +44,7 @@ static b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThread
b3PosixThreadSupport::ThreadConstructionInfo constructionInfo("testThreads",
ExampleBrowserThreadFunc,
ExampleBrowserMemoryFunc,
ExampleBrowserMemoryReleaseFunc,
numThreads);
b3ThreadSupportInterface* threadSupport = new b3PosixThreadSupport(constructionInfo);
@@ -56,7 +59,7 @@ static b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThread
b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThreads)
{
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads",ExampleBrowserThreadFunc,ExampleBrowserMemoryFunc,numThreads);
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads",ExampleBrowserThreadFunc,ExampleBrowserMemoryFunc,ExampleBrowserMemoryReleaseFunc,numThreads);
b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport(threadConstructionInfo);
return threadSupport;
@@ -303,6 +306,12 @@ void* ExampleBrowserMemoryFunc()
return new ExampleBrowserThreadLocalStorage;
}
void ExampleBrowserMemoryReleaseFunc(void* ptr)
{
ExampleBrowserThreadLocalStorage* p = (ExampleBrowserThreadLocalStorage*) ptr;
delete p;
}

View File

@@ -410,6 +410,14 @@ void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable)
if (flag == COV_ENABLE_WIREFRAME)
{
visualWireframe = enable;
if (visualWireframe)
{
gDebugDrawFlags |= btIDebugDraw::DBG_DrawWireframe;
}
else
{
gDebugDrawFlags &= ~btIDebugDraw::DBG_DrawWireframe;
}
}
}
@@ -1257,7 +1265,7 @@ void OpenGLExampleBrowser::update(float deltaTime)
{
skip=gPngSkipFrames;
//printf("gPngFileName=%s\n",gPngFileName);
static int s_frameCount = 100;
static int s_frameCount = 0;
sprintf(staticPngFileName,"%s%d.png",gPngFileName,s_frameCount++);
//b3Printf("Made screenshot %s",staticPngFileName);

View File

@@ -433,10 +433,14 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli
if (collisionShape->getShapeType() == SOFTBODY_SHAPE_PROXYTYPE)
{
computeSoftBodyVertices(collisionShape, gfxVertices, indices);
int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES,
m_data->m_checkedTexture);
b3Assert(shapeId >= 0);
collisionShape->setUserIndex(shapeId);
if (gfxVertices.size() && indices.size())
{
int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES,
m_data->m_checkedTexture);
b3Assert(shapeId >= 0);
collisionShape->setUserIndex(shapeId);
}
}
if (collisionShape->getShapeType()==MULTI_SPHERE_SHAPE_PROXYTYPE)
{
@@ -1026,6 +1030,10 @@ void OpenGLGuiHelper::setVisualizerFlagCallback(VisualizerFlagCallback callback)
void OpenGLGuiHelper::setVisualizerFlag(int flag, int enable)
{
if (getRenderInterface() && flag==16)//COV_ENABLE_PLANAR_REFLECTION
{
getRenderInterface()->setPlaneReflectionShapeIndex(enable);
}
if (m_data->m_visualizerFlagCallback)
(m_data->m_visualizerFlagCallback)(flag,enable);
}
@@ -1261,6 +1269,11 @@ void OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWor
btCollisionObject* colObj = sortedObjects[i];
//btRigidBody* body = btRigidBody::upcast(colObj);
//does this also work for btMultiBody/btMultiBodyLinkCollider?
btSoftBody* sb = btSoftBody::upcast(colObj);
if (sb)
{
colObj->getCollisionShape()->setUserPointer(sb);
}
createCollisionShapeGraphicsObject(colObj->getCollisionShape());
int colorIndex = colObj->getBroadphaseHandle()->getUid() & 3;
@@ -1309,6 +1322,8 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape,
btAlignedObjectArray<GLInstanceVertex>& gfxVertices,
btAlignedObjectArray<int>& indices)
{
if (collisionShape->getUserPointer()==0)
return;
b3Assert(collisionShape->getUserPointer());
btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer();
gfxVertices.resize(psb->m_faces.size() * 3);

View File

@@ -164,14 +164,11 @@ project "App_BulletExampleBrowser"
"../RigidBody/RigidBodySoftContact.cpp",
"../ThirdPartyLibs/stb_image/*",
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.*",
"../ThirdPartyLibs/tinyxml/*",
"../ThirdPartyLibs/BussIK/*",
"../GyroscopicDemo/GyroscopicSetup.cpp",
"../GyroscopicDemo/GyroscopicSetup.h",
"../ThirdPartyLibs/tinyxml/tinystr.cpp",
"../ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../ThirdPartyLibs/tinyxml2/tinyxml2.h",
}
if (hasCL and findOpenGL3()) then
files {

View File

@@ -121,6 +121,7 @@ void SimpleClothExample::createSoftBody(const btScalar s,
fixed,true);
cloth->getCollisionShape()->setMargin(0.001f);
cloth->getCollisionShape()->setUserPointer((void*)cloth);
cloth->generateBendingConstraints(2,cloth->appendMaterial());
cloth->setTotalMass(10);
//cloth->m_cfg.citerations = 10;

View File

@@ -20,7 +20,8 @@ subject to the following restrictions:
#include <stdio.h> //fopen
#include "Bullet3Common/b3AlignedObjectArray.h"
#include <string>
#include "../../ThirdPartyLibs/tinyxml/tinyxml.h"
#include "../../ThirdPartyLibs/tinyxml2/tinyxml2.h"
using namespace tinyxml2;
#include "Bullet3Common/b3FileUtils.h"
#include "LinearMath/btHashMap.h"
@@ -90,14 +91,14 @@ void tokenize(const std::string& str, AddToken& tokenAdder, const std::string& d
}
void readFloatArray(TiXmlElement* source, btAlignedObjectArray<float>& floatArray, int& componentStride)
void readFloatArray(XMLElement* source, btAlignedObjectArray<float>& floatArray, int& componentStride)
{
int numVals, stride;
TiXmlElement* array = source->FirstChildElement("float_array");
XMLElement* array = source->FirstChildElement("float_array");
if(array)
{
componentStride = 1;
if (source->FirstChildElement("technique_common")->FirstChildElement("accessor")->QueryIntAttribute("stride", &stride)!= TIXML_NO_ATTRIBUTE)
if (source->FirstChildElement("technique_common")->FirstChildElement("accessor")->QueryIntAttribute("stride", &stride)!= XML_NO_ATTRIBUTE)
{
componentStride = stride;
}
@@ -140,11 +141,11 @@ btVector4 getVector4FromXmlText(const char* text)
}
void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGraphicsShape>& visualShapes, btHashMap<btHashString,int>& name2Shape, float extraScaling)
void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArray<GLInstanceGraphicsShape>& visualShapes, btHashMap<btHashString,int>& name2Shape, float extraScaling)
{
btHashMap<btHashString,TiXmlElement* > allSources;
btHashMap<btHashString,XMLElement* > allSources;
btHashMap<btHashString,VertexSource> vertexSources;
for(TiXmlElement* geometry = doc.RootElement()->FirstChildElement("library_geometries")->FirstChildElement("geometry");
for(XMLElement* geometry = doc.RootElement()->FirstChildElement("library_geometries")->FirstChildElement("geometry");
geometry != NULL; geometry = geometry->NextSiblingElement("geometry"))
{
btAlignedObjectArray<btVector3> vertexPositions;
@@ -152,11 +153,11 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
btAlignedObjectArray<int> indices;
const char* geometryName = geometry->Attribute("id");
for (TiXmlElement* mesh = geometry->FirstChildElement("mesh");(mesh != NULL); mesh = mesh->NextSiblingElement("mesh"))
for (XMLElement* mesh = geometry->FirstChildElement("mesh");(mesh != NULL); mesh = mesh->NextSiblingElement("mesh"))
{
TiXmlElement* vertices2 = mesh->FirstChildElement("vertices");
XMLElement* vertices2 = mesh->FirstChildElement("vertices");
for (TiXmlElement* source = mesh->FirstChildElement("source");source != NULL;source = source->NextSiblingElement("source"))
for (XMLElement* source = mesh->FirstChildElement("source");source != NULL;source = source->NextSiblingElement("source"))
{
const char* srcId= source->Attribute("id");
// printf("source id=%s\n",srcId);
@@ -165,7 +166,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
const char* vertexId = vertices2->Attribute("id");
//printf("vertices id=%s\n",vertexId);
VertexSource vs;
for(TiXmlElement* input = vertices2->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input"))
for(XMLElement* input = vertices2->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input"))
{
const char* sem = input->Attribute("semantic");
std::string semName(sem);
@@ -187,7 +188,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
}
vertexSources.insert(vertexId,vs);
for (TiXmlElement* primitive = mesh->FirstChildElement("triangles"); primitive; primitive = primitive->NextSiblingElement("triangles"))
for (XMLElement* primitive = mesh->FirstChildElement("triangles"); primitive; primitive = primitive->NextSiblingElement("triangles"))
{
std::string positionSourceName;
std::string normalSourceName;
@@ -199,7 +200,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
int numIndices = 0;
{
for (TiXmlElement* input = primitive->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input"))
for (XMLElement* input = primitive->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input"))
{
const char* sem = input->Attribute("semantic");
std::string semName(sem);
@@ -241,7 +242,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
}
btAlignedObjectArray<float> positionFloatArray;
int posStride=1;
TiXmlElement** sourcePtr = allSources[positionSourceName.c_str()];
XMLElement** sourcePtr = allSources[positionSourceName.c_str()];
if (sourcePtr)
{
readFloatArray(*sourcePtr,positionFloatArray, posStride);
@@ -334,7 +335,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
}//for each geometry
}
void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shape, btAlignedObjectArray<ColladaGraphicsInstance>& visualShapeInstances, const btMatrix4x4& parentTransMat)
void readNodeHierarchy(XMLElement* node,btHashMap<btHashString,int>& name2Shape, btAlignedObjectArray<ColladaGraphicsInstance>& visualShapeInstances, const btMatrix4x4& parentTransMat)
{
@@ -343,7 +344,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shap
///todo(erwincoumans) we probably have to read the elements 'translate', 'scale', 'rotate' and 'matrix' in-order and accumulate them...
{
for (TiXmlElement* transElem = node->FirstChildElement("matrix");transElem;transElem=node->NextSiblingElement("matrix"))
for (XMLElement* transElem = node->FirstChildElement("matrix");transElem;transElem=node->NextSiblingElement("matrix"))
{
if (transElem->GetText())
{
@@ -367,7 +368,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shap
}
{
for (TiXmlElement* transElem = node->FirstChildElement("translate");transElem;transElem=node->NextSiblingElement("translate"))
for (XMLElement* transElem = node->FirstChildElement("translate");transElem;transElem=node->NextSiblingElement("translate"))
{
if (transElem->GetText())
{
@@ -381,7 +382,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shap
}
}
{
for(TiXmlElement* scaleElem = node->FirstChildElement("scale");
for(XMLElement* scaleElem = node->FirstChildElement("scale");
scaleElem!= NULL; scaleElem= node->NextSiblingElement("scale"))
{
if (scaleElem->GetText())
@@ -394,7 +395,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shap
}
}
{
for(TiXmlElement* rotateElem = node->FirstChildElement("rotate");
for(XMLElement* rotateElem = node->FirstChildElement("rotate");
rotateElem!= NULL; rotateElem= node->NextSiblingElement("rotate"))
{
if (rotateElem->GetText())
@@ -411,7 +412,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shap
nodeTrans = parentTransMat*nodeTrans;
for (TiXmlElement* instanceGeom = node->FirstChildElement("instance_geometry");
for (XMLElement* instanceGeom = node->FirstChildElement("instance_geometry");
instanceGeom!=0;
instanceGeom=instanceGeom->NextSiblingElement("instance_geometry"))
{
@@ -432,22 +433,22 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap<btHashString,int>& name2Shap
}
}
for(TiXmlElement* childNode = node->FirstChildElement("node");
for(XMLElement* childNode = node->FirstChildElement("node");
childNode!= NULL; childNode = childNode->NextSiblingElement("node"))
{
readNodeHierarchy(childNode,name2Shape,visualShapeInstances, nodeTrans);
}
}
void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMap<btHashString,int>& name2Shape, btAlignedObjectArray<ColladaGraphicsInstance>& visualShapeInstances)
void readVisualSceneInstanceGeometries(XMLDocument& doc, btHashMap<btHashString,int>& name2Shape, btAlignedObjectArray<ColladaGraphicsInstance>& visualShapeInstances)
{
btHashMap<btHashString,TiXmlElement* > allVisualScenes;
btHashMap<btHashString,XMLElement* > allVisualScenes;
TiXmlElement* libVisualScenes = doc.RootElement()->FirstChildElement("library_visual_scenes");
XMLElement* libVisualScenes = doc.RootElement()->FirstChildElement("library_visual_scenes");
if (libVisualScenes==0)
return;
{
for(TiXmlElement* scene = libVisualScenes->FirstChildElement("visual_scene");
for(XMLElement* scene = libVisualScenes->FirstChildElement("visual_scene");
scene != NULL; scene = scene->NextSiblingElement("visual_scene"))
{
const char* sceneName = scene->Attribute("id");
@@ -455,16 +456,16 @@ void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMap<btHashStrin
}
}
TiXmlElement* scene = 0;
XMLElement* scene = 0;
{
TiXmlElement* scenes = doc.RootElement()->FirstChildElement("scene");
XMLElement* scenes = doc.RootElement()->FirstChildElement("scene");
if (scenes)
{
TiXmlElement* instanceSceneReference = scenes->FirstChildElement("instance_visual_scene");
XMLElement* instanceSceneReference = scenes->FirstChildElement("instance_visual_scene");
if (instanceSceneReference)
{
const char* instanceSceneUrl = instanceSceneReference->Attribute("url");
TiXmlElement** sceneInstancePtr = allVisualScenes[instanceSceneUrl+1];//skip #
XMLElement** sceneInstancePtr = allVisualScenes[instanceSceneUrl+1];//skip #
if (sceneInstancePtr)
{
scene = *sceneInstancePtr;
@@ -475,7 +476,7 @@ void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMap<btHashStrin
if (scene)
{
for(TiXmlElement* node = scene->FirstChildElement("node");
for(XMLElement* node = scene->FirstChildElement("node");
node != NULL; node = node->NextSiblingElement("node"))
{
btMatrix4x4 identity;
@@ -488,11 +489,11 @@ void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMap<btHashStrin
}
}
void getUnitMeterScalingAndUpAxisTransform(TiXmlDocument& doc, btTransform& tr, float& unitMeterScaling, int clientUpAxis)
void getUnitMeterScalingAndUpAxisTransform(XMLDocument& doc, btTransform& tr, float& unitMeterScaling, int clientUpAxis)
{
///todo(erwincoumans) those up-axis transformations have been quickly coded without rigorous testing
TiXmlElement* unitMeter = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("unit");
XMLElement* unitMeter = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("unit");
if (unitMeter)
{
const char* meterText = unitMeter->Attribute("meter");
@@ -500,7 +501,7 @@ void getUnitMeterScalingAndUpAxisTransform(TiXmlDocument& doc, btTransform& tr,
unitMeterScaling = atof(meterText);
}
TiXmlElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis");
XMLElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis");
if (upAxisElem)
{
switch (clientUpAxis)
@@ -573,8 +574,8 @@ void LoadMeshFromCollada(const char* relativeFileName, btAlignedObjectArray<GLIn
return;
}
TiXmlDocument doc(filename);
if (!doc.LoadFile())
XMLDocument doc;
if (doc.LoadFile(filename) != XML_SUCCESS)
return;
//We need units to be in meter, so apply a scaling using the asset/units meter

View File

@@ -1,5 +1,5 @@
#include "BulletMJCFImporter.h"
#include "../../ThirdPartyLibs/tinyxml/tinyxml.h"
#include "../../ThirdPartyLibs/tinyxml2/tinyxml2.h"
#include "Bullet3Common/b3FileUtils.h"
#include "Bullet3Common/b3HashMap.h"
#include "LinearMath/btQuickprof.h"
@@ -32,7 +32,7 @@
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
using namespace tinyxml2;
@@ -232,7 +232,7 @@ struct BulletMJCFImporterInternalData
}
}
std::string sourceFileLocation(TiXmlElement* e)
std::string sourceFileLocation(XMLElement* e)
{
#if 0
//no C++11 snprintf etc
@@ -241,7 +241,7 @@ struct BulletMJCFImporterInternalData
return buf;
#else
char row[1024];
sprintf(row,"%d",e->Row());
sprintf(row,"%d",e->GetLineNum());
std::string str = m_sourceFileName.c_str() + std::string(":") + std::string(row);
return str;
#endif
@@ -261,7 +261,7 @@ struct BulletMJCFImporterInternalData
return 0;
}
void parseCompiler(TiXmlElement* root_xml, MJCFErrorLogger* logger)
void parseCompiler(XMLElement* root_xml, MJCFErrorLogger* logger)
{
const char* meshDirStr = root_xml->Attribute("meshdir");
@@ -284,10 +284,10 @@ struct BulletMJCFImporterInternalData
}
void parseAssets(TiXmlElement* root_xml, MJCFErrorLogger* logger)
void parseAssets(XMLElement* root_xml, MJCFErrorLogger* logger)
{
// <mesh name="index0" file="index0.stl"/>
for (TiXmlElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement())
for (XMLElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement())
{
std::string n = child_xml->Value();
if (n=="mesh")
@@ -307,11 +307,11 @@ struct BulletMJCFImporterInternalData
}
bool parseDefaults(MyMJCFDefaults& defaults, TiXmlElement* root_xml, MJCFErrorLogger* logger)
bool parseDefaults(MyMJCFDefaults& defaults, XMLElement* root_xml, MJCFErrorLogger* logger)
{
bool handled= false;
//rudimentary 'default' support, would need more work for better feature coverage
for (TiXmlElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement())
for (XMLElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement())
{
std::string n = child_xml->Value();
@@ -413,9 +413,9 @@ struct BulletMJCFImporterInternalData
handled=true;
return handled;
}
bool parseRootLevel(MyMJCFDefaults& defaults, TiXmlElement* root_xml,MJCFErrorLogger* logger)
bool parseRootLevel(MyMJCFDefaults& defaults, XMLElement* root_xml,MJCFErrorLogger* logger)
{
for (TiXmlElement* rootxml = root_xml->FirstChildElement() ; rootxml ; rootxml = rootxml->NextSiblingElement())
for (XMLElement* rootxml = root_xml->FirstChildElement() ; rootxml ; rootxml = rootxml->NextSiblingElement())
{
bool handled = false;
std::string n = rootxml->Value();
@@ -473,7 +473,7 @@ struct BulletMJCFImporterInternalData
return true;
}
bool parseJoint(MyMJCFDefaults& defaults, TiXmlElement* link_xml, int modelIndex, int parentLinkIndex, int linkIndex, MJCFErrorLogger* logger, const btTransform& parentToLinkTrans, btTransform& jointTransOut)
bool parseJoint(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int parentLinkIndex, int linkIndex, MJCFErrorLogger* logger, const btTransform& parentToLinkTrans, btTransform& jointTransOut)
{
bool jointHandled = false;
const char* jType = link_xml->Attribute("type");
@@ -649,7 +649,7 @@ struct BulletMJCFImporterInternalData
*/
return false;
}
bool parseGeom(MyMJCFDefaults& defaults, TiXmlElement* link_xml, int modelIndex, int linkIndex, MJCFErrorLogger* logger, btVector3& inertialShift)
bool parseGeom(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int linkIndex, MJCFErrorLogger* logger, btVector3& inertialShift)
{
UrdfLink** linkPtrPtr = m_models[modelIndex]->m_links.getAtIndex(linkIndex);
if (linkPtrPtr==0)
@@ -963,7 +963,7 @@ struct BulletMJCFImporterInternalData
return handledGeomType;
}
btTransform parseTransform(TiXmlElement* link_xml, MJCFErrorLogger* logger)
btTransform parseTransform(XMLElement* link_xml, MJCFErrorLogger* logger)
{
btTransform tr;
tr.setIdentity();
@@ -1032,6 +1032,11 @@ struct BulletMJCFImporterInternalData
//todo
break;
}
case URDF_GEOM_CDF:
{
//todo
break;
}
case URDF_GEOM_CYLINDER:
case URDF_GEOM_CAPSULE:
{
@@ -1090,7 +1095,7 @@ struct BulletMJCFImporterInternalData
return orgChildLinkIndex;
}
bool parseBody(MyMJCFDefaults& defaults, TiXmlElement* link_xml, int modelIndex, int orgParentLinkIndex, MJCFErrorLogger* logger)
bool parseBody(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int orgParentLinkIndex, MJCFErrorLogger* logger)
{
MyMJCFDefaults curDefaults = defaults;
@@ -1142,7 +1147,7 @@ struct BulletMJCFImporterInternalData
jointTrans.setIdentity();
bool skipFixedJoint = false;
for (TiXmlElement* xml = link_xml->FirstChildElement() ; xml ; xml = xml->NextSiblingElement())
for (XMLElement* xml = link_xml->FirstChildElement() ; xml ; xml = xml->NextSiblingElement())
{
bool handled = false;
std::string n = xml->Value();
@@ -1482,16 +1487,16 @@ bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger,
bool BulletMJCFImporter::parseMJCFString(const char* xmlText, MJCFErrorLogger* logger)
{
TiXmlDocument xml_doc;
XMLDocument xml_doc;
xml_doc.Parse(xmlText);
if (xml_doc.Error())
{
logger->reportError(xml_doc.ErrorDesc());
logger->reportError(xml_doc.ErrorStr());
xml_doc.ClearError();
return false;
}
TiXmlElement *mujoco_xml = xml_doc.FirstChildElement("mujoco");
XMLElement *mujoco_xml = xml_doc.FirstChildElement("mujoco");
if (!mujoco_xml)
{
logger->reportWarning("Cannot find <mujoco> root element");
@@ -1507,28 +1512,28 @@ bool BulletMJCFImporter::parseMJCFString(const char* xmlText, MJCFErrorLogger* l
//<compiler>,<option>,<size>,<default>,<body>,<keyframe>,<contactpair>,
//<light>, <camera>,<constraint>,<tendon>,<actuator>,<customfield>,<textfield>
for (TiXmlElement* link_xml = mujoco_xml->FirstChildElement("default"); link_xml; link_xml = link_xml->NextSiblingElement("default"))
for (XMLElement* link_xml = mujoco_xml->FirstChildElement("default"); link_xml; link_xml = link_xml->NextSiblingElement("default"))
{
m_data->parseDefaults(m_data->m_globalDefaults,link_xml,logger);
}
for (TiXmlElement* link_xml = mujoco_xml->FirstChildElement("compiler"); link_xml; link_xml = link_xml->NextSiblingElement("compiler"))
for (XMLElement* link_xml = mujoco_xml->FirstChildElement("compiler"); link_xml; link_xml = link_xml->NextSiblingElement("compiler"))
{
m_data->parseCompiler(link_xml,logger);
}
for (TiXmlElement* link_xml = mujoco_xml->FirstChildElement("asset"); link_xml; link_xml = link_xml->NextSiblingElement("asset"))
for (XMLElement* link_xml = mujoco_xml->FirstChildElement("asset"); link_xml; link_xml = link_xml->NextSiblingElement("asset"))
{
m_data->parseAssets(link_xml,logger);
}
for (TiXmlElement* link_xml = mujoco_xml->FirstChildElement("body"); link_xml; link_xml = link_xml->NextSiblingElement("body"))
for (XMLElement* link_xml = mujoco_xml->FirstChildElement("body"); link_xml; link_xml = link_xml->NextSiblingElement("body"))
{
m_data->parseRootLevel(m_data->m_globalDefaults, link_xml,logger);
}
for (TiXmlElement* link_xml = mujoco_xml->FirstChildElement("worldbody"); link_xml; link_xml = link_xml->NextSiblingElement("worldbody"))
for (XMLElement* link_xml = mujoco_xml->FirstChildElement("worldbody"); link_xml; link_xml = link_xml->NextSiblingElement("worldbody"))
{
m_data->parseRootLevel(m_data->m_globalDefaults, link_xml,logger);
}
@@ -2541,6 +2546,11 @@ class btCompoundShape* BulletMJCFImporter::convertLinkCollisionShapes( int linkI
}
break;
}
case URDF_GEOM_CDF:
{
//todo
break;
}
case URDF_GEOM_UNKNOWN:
{
break;

View File

@@ -2,7 +2,8 @@
#include "../../OpenGLWindow/GLInstancingRenderer.h"
#include "../../OpenGLWindow/GLInstanceGraphicsShape.h"
#include "btBulletDynamicsCommon.h"
//#include "btBulletDynamicsCommon.h"
#include "LinearMath/btVector3.h"
#include "../../OpenGLWindow/SimpleOpenGL3App.h"
#include "Wavefront2GLInstanceGraphicsShape.h"
#include "../../OpenGLWindow/GLInstancingRenderer.h"

View File

@@ -21,6 +21,7 @@ subject to the following restrictions:
#include "../ImportSTLDemo/LoadMeshFromSTL.h"
#include "../ImportColladaDemo/LoadMeshFromCollada.h"
#include "BulletCollision/CollisionShapes/btShapeHull.h"//to create a tesselation of a generic btConvexShape
#include "BulletCollision/CollisionShapes/btSdfCollisionShape.h"
#include "../../CommonInterfaces/CommonGUIHelperInterface.h"
#include "Bullet3Common/b3FileUtils.h"
#include <string>
@@ -509,6 +510,10 @@ bool findExistingMeshFile(
{
*out_type = UrdfGeometry::FILE_OBJ;
}
else if (ext == ".cdf")
{
*out_type = UrdfGeometry::FILE_CDF;
}
else
{
b3Warning("%s: invalid mesh filename extension '%s'\n", error_message_prefix.c_str(), ext.c_str());
@@ -662,7 +667,53 @@ btCollisionShape* BulletURDFImporter::convertURDFToCollisionShape(const UrdfColl
shape ->setMargin(gUrdfDefaultCollisionMargin);
break;
}
case URDF_GEOM_CDF:
{
char relativeFileName[1024];
char pathPrefix[1024];
pathPrefix[0] = 0;
if (b3ResourcePath::findResourcePath(collision->m_geometry.m_meshFileName.c_str(), relativeFileName, 1024))
{
b3FileUtils::extractPath(relativeFileName, pathPrefix, 1024);
btAlignedObjectArray<char> sdfData;
{
std::streampos fsize = 0;
std::ifstream file(relativeFileName, std::ios::binary);
if (file.good())
{
fsize = file.tellg();
file.seekg(0, std::ios::end);
fsize = file.tellg() - fsize;
file.seekg(0, std::ios::beg);
sdfData.resize(fsize);
int bytesRead = file.rdbuf()->sgetn(&sdfData[0], fsize);
btAssert(bytesRead == fsize);
file.close();
}
}
if (sdfData.size())
{
btSdfCollisionShape* sdfShape = new btSdfCollisionShape();
bool valid = sdfShape->initializeSDF(&sdfData[0], sdfData.size());
btAssert(valid);
if (valid)
{
shape = sdfShape;
}
else
{
delete sdfShape;
}
}
}
break;
}
case URDF_GEOM_MESH:
{
GLInstanceGraphicsShape* glmesh = 0;

View File

@@ -1,8 +1,9 @@
#include "UrdfParser.h"
#include "../../ThirdPartyLibs/tinyxml/tinyxml.h"
#include "../../ThirdPartyLibs/tinyxml2/tinyxml2.h"
#include "urdfStringSplit.h"
#include "urdfLexicalCast.h"
using namespace tinyxml2;
UrdfParser::UrdfParser()
:m_parseSDF(false),
@@ -74,7 +75,7 @@ static bool parseVector3(btVector3& vec3, const std::string& vector_str, ErrorLo
return true;
}
bool UrdfParser::parseMaterial(UrdfMaterial& material, TiXmlElement *config, ErrorLogger* logger)
bool UrdfParser::parseMaterial(UrdfMaterial& material, XMLElement *config, ErrorLogger* logger)
{
if (!config->Attribute("name"))
@@ -86,7 +87,7 @@ bool UrdfParser::parseMaterial(UrdfMaterial& material, TiXmlElement *config, Err
material.m_name = config->Attribute("name");
// texture
TiXmlElement *t = config->FirstChildElement("texture");
XMLElement *t = config->FirstChildElement("texture");
if (t)
{
if (t->Attribute("filename"))
@@ -102,7 +103,7 @@ bool UrdfParser::parseMaterial(UrdfMaterial& material, TiXmlElement *config, Err
// color
{
TiXmlElement *c = config->FirstChildElement("color");
XMLElement *c = config->FirstChildElement("color");
if (c)
{
if (c->Attribute("rgba"))
@@ -118,7 +119,7 @@ bool UrdfParser::parseMaterial(UrdfMaterial& material, TiXmlElement *config, Err
{
// specular (non-standard)
TiXmlElement *s = config->FirstChildElement("specular");
XMLElement *s = config->FirstChildElement("specular");
if (s)
{
if (s->Attribute("rgb"))
@@ -133,7 +134,7 @@ bool UrdfParser::parseMaterial(UrdfMaterial& material, TiXmlElement *config, Err
}
bool UrdfParser::parseTransform(btTransform& tr, TiXmlElement* xml, ErrorLogger* logger, bool parseSDF )
bool UrdfParser::parseTransform(btTransform& tr, XMLElement* xml, ErrorLogger* logger, bool parseSDF )
{
tr.setIdentity();
@@ -207,13 +208,13 @@ bool UrdfParser::parseTransform(btTransform& tr, TiXmlElement* xml, ErrorLogger*
return true;
}
bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorLogger* logger)
bool UrdfParser::parseInertia(UrdfInertia& inertia, XMLElement* config, ErrorLogger* logger)
{
inertia.m_linkLocalFrame.setIdentity();
inertia.m_mass = 0.f;
if(m_parseSDF)
{
TiXmlElement* pose = config->FirstChildElement("pose");
XMLElement* pose = config->FirstChildElement("pose");
if (pose)
{
parseTransform(inertia.m_linkLocalFrame, pose,logger,m_parseSDF);
@@ -223,7 +224,7 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
// Origin
TiXmlElement *o = config->FirstChildElement("origin");
XMLElement *o = config->FirstChildElement("origin");
if (o)
{
if (!parseTransform(inertia.m_linkLocalFrame,o,logger))
@@ -232,7 +233,7 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
}
}
TiXmlElement *mass_xml = config->FirstChildElement("mass");
XMLElement *mass_xml = config->FirstChildElement("mass");
if (!mass_xml)
{
logger->reportError("Inertial element must have a mass element");
@@ -252,7 +253,7 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
inertia.m_mass = urdfLexicalCast<double>(mass_xml->Attribute("value"));
}
TiXmlElement *inertia_xml = config->FirstChildElement("inertia");
XMLElement *inertia_xml = config->FirstChildElement("inertia");
if (!inertia_xml)
{
logger->reportError("Inertial element must have inertia element");
@@ -260,12 +261,12 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
}
if (m_parseSDF)
{
TiXmlElement* ixx = inertia_xml->FirstChildElement("ixx");
TiXmlElement* ixy = inertia_xml->FirstChildElement("ixy");
TiXmlElement* ixz = inertia_xml->FirstChildElement("ixz");
TiXmlElement* iyy = inertia_xml->FirstChildElement("iyy");
TiXmlElement* iyz = inertia_xml->FirstChildElement("iyz");
TiXmlElement* izz = inertia_xml->FirstChildElement("izz");
XMLElement* ixx = inertia_xml->FirstChildElement("ixx");
XMLElement* ixy = inertia_xml->FirstChildElement("ixy");
XMLElement* ixz = inertia_xml->FirstChildElement("ixz");
XMLElement* iyy = inertia_xml->FirstChildElement("iyy");
XMLElement* iyz = inertia_xml->FirstChildElement("iyz");
XMLElement* izz = inertia_xml->FirstChildElement("izz");
if (ixx && ixy && ixz && iyy && iyz && izz)
{
inertia.m_ixx = urdfLexicalCast<double>(ixx->GetText());
@@ -324,20 +325,21 @@ bool UrdfParser::parseInertia(UrdfInertia& inertia, TiXmlElement* config, ErrorL
}
bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger* logger)
bool UrdfParser::parseGeometry(UrdfGeometry& geom, XMLElement* g, ErrorLogger* logger)
{
// btAssert(g);
if (g==0)
return false;
TiXmlElement *shape = g->FirstChildElement();
XMLElement *shape = g->FirstChildElement();
if (!shape)
{
logger->reportError("Geometry tag contains no child element.");
return false;
}
const std::string type_name = shape->ValueTStr().c_str();
//const std::string type_name = shape->ValueTStr().c_str();
const std::string type_name = shape->Value();
if (type_name == "sphere")
{
geom.m_type = URDF_GEOM_SPHERE;
@@ -355,7 +357,7 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
geom.m_type = URDF_GEOM_BOX;
if (m_parseSDF)
{
TiXmlElement* size = shape->FirstChildElement("size");
XMLElement* size = shape->FirstChildElement("size");
if (0==size)
{
logger->reportError("box requires a size child element");
@@ -386,12 +388,12 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
if (m_parseSDF)
{
if (TiXmlElement* scale = shape->FirstChildElement("radius"))
if (XMLElement* scale = shape->FirstChildElement("radius"))
{
parseVector3(geom.m_meshScale,scale->GetText(),logger);
geom.m_capsuleRadius = m_urdfScaling * urdfLexicalCast<double>(scale->GetText());
}
if (TiXmlElement* scale = shape->FirstChildElement("length"))
if (XMLElement* scale = shape->FirstChildElement("length"))
{
parseVector3(geom.m_meshScale,scale->GetText(),logger);
geom.m_capsuleHeight = m_urdfScaling * urdfLexicalCast<double>(scale->GetText());
@@ -413,12 +415,12 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
geom.m_hasFromTo = false;
if (m_parseSDF)
{
if (TiXmlElement* scale = shape->FirstChildElement("radius"))
if (XMLElement* scale = shape->FirstChildElement("radius"))
{
parseVector3(geom.m_meshScale,scale->GetText(),logger);
geom.m_capsuleRadius = m_urdfScaling * urdfLexicalCast<double>(scale->GetText());
}
if (TiXmlElement* scale = shape->FirstChildElement("length"))
if (XMLElement* scale = shape->FirstChildElement("length"))
{
parseVector3(geom.m_meshScale,scale->GetText(),logger);
geom.m_capsuleHeight = m_urdfScaling * urdfLexicalCast<double>(scale->GetText());
@@ -434,19 +436,26 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
geom.m_capsuleHeight = m_urdfScaling * urdfLexicalCast<double>(shape->Attribute("length"));
}
}
else if (type_name == "mesh")
else if ((type_name == "mesh") || (type_name == "cdf"))
{
geom.m_type = URDF_GEOM_MESH;
if ((type_name == "cdf"))
{
geom.m_type = URDF_GEOM_CDF;
}
else
{
geom.m_type = URDF_GEOM_MESH;
}
geom.m_meshScale.setValue(1,1,1);
std::string fn;
if (m_parseSDF)
{
if (TiXmlElement* scale = shape->FirstChildElement("scale"))
if (XMLElement* scale = shape->FirstChildElement("scale"))
{
parseVector3(geom.m_meshScale,scale->GetText(),logger);
}
if (TiXmlElement* filename = shape->FirstChildElement("uri"))
if (XMLElement* filename = shape->FirstChildElement("uri"))
{
fn = filename->GetText();
}
@@ -498,8 +507,8 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
geom.m_type = URDF_GEOM_PLANE;
if (this->m_parseSDF)
{
TiXmlElement *n = shape->FirstChildElement("normal");
TiXmlElement *s = shape->FirstChildElement("size");
XMLElement *n = shape->FirstChildElement("normal");
XMLElement *s = shape->FirstChildElement("size");
if ((0==n)||(0==s))
{
@@ -535,14 +544,14 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
}
bool UrdfParser::parseCollision(UrdfCollision& collision, TiXmlElement* config, ErrorLogger* logger)
bool UrdfParser::parseCollision(UrdfCollision& collision, XMLElement* config, ErrorLogger* logger)
{
collision.m_linkLocalFrame.setIdentity();
if(m_parseSDF)
{
TiXmlElement* pose = config->FirstChildElement("pose");
XMLElement* pose = config->FirstChildElement("pose");
if (pose)
{
parseTransform(collision.m_linkLocalFrame, pose,logger,m_parseSDF);
@@ -550,14 +559,14 @@ bool UrdfParser::parseCollision(UrdfCollision& collision, TiXmlElement* config,
}
// Origin
TiXmlElement *o = config->FirstChildElement("origin");
XMLElement *o = config->FirstChildElement("origin");
if (o)
{
if (!parseTransform(collision.m_linkLocalFrame, o,logger))
return false;
}
// Geometry
TiXmlElement *geom = config->FirstChildElement("geometry");
XMLElement *geom = config->FirstChildElement("geometry");
if (!parseGeometry(collision.m_geometry,geom,logger))
{
return false;
@@ -575,12 +584,12 @@ bool UrdfParser::parseCollision(UrdfCollision& collision, TiXmlElement* config,
return true;
}
bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement* config, ErrorLogger* logger)
bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, XMLElement* config, ErrorLogger* logger)
{
visual.m_linkLocalFrame.setIdentity();
if(m_parseSDF)
{
TiXmlElement* pose = config->FirstChildElement("pose");
XMLElement* pose = config->FirstChildElement("pose");
if (pose)
{
parseTransform(visual.m_linkLocalFrame, pose,logger,m_parseSDF);
@@ -588,14 +597,14 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
}
// Origin
TiXmlElement *o = config->FirstChildElement("origin");
XMLElement *o = config->FirstChildElement("origin");
if (o)
{
if (!parseTransform(visual.m_linkLocalFrame, o,logger))
return false;
}
// Geometry
TiXmlElement *geom = config->FirstChildElement("geometry");
XMLElement *geom = config->FirstChildElement("geometry");
if (!parseGeometry(visual.m_geometry,geom,logger))
{
return false;
@@ -609,7 +618,7 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
visual.m_geometry.m_hasLocalMaterial = false;
// Material
TiXmlElement *mat = config->FirstChildElement("material");
XMLElement *mat = config->FirstChildElement("material");
//todo(erwincoumans) skip materials in SDF for now (due to complexity)
if (mat)
{
@@ -630,7 +639,7 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
}
model.m_materials.insert(matPtr->m_name.c_str(),matPtr);
{
TiXmlElement *diffuse = mat->FirstChildElement("diffuse");
XMLElement *diffuse = mat->FirstChildElement("diffuse");
if (diffuse) {
std::string diffuseText = diffuse->GetText();
btVector4 rgba(1,0,0,1);
@@ -642,7 +651,7 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
}
}
{
TiXmlElement *specular = mat->FirstChildElement("specular");
XMLElement *specular = mat->FirstChildElement("specular");
if (specular) {
std::string specularText = specular->GetText();
btVector3 rgba(1,1,1);
@@ -665,9 +674,9 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
// try to parse material element in place
TiXmlElement *t = mat->FirstChildElement("texture");
TiXmlElement *c = mat->FirstChildElement("color");
TiXmlElement *s = mat->FirstChildElement("specular");
XMLElement *t = mat->FirstChildElement("texture");
XMLElement *c = mat->FirstChildElement("color");
XMLElement *s = mat->FirstChildElement("specular");
if (t||c||s)
{
if (parseMaterial(visual.m_geometry.m_localMaterial, mat,logger))
@@ -692,7 +701,7 @@ bool UrdfParser::parseVisual(UrdfModel& model, UrdfVisual& visual, TiXmlElement*
return true;
}
bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *config, ErrorLogger* logger)
bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, XMLElement *config, ErrorLogger* logger)
{
const char* linkName = config->Attribute("name");
if (!linkName)
@@ -705,7 +714,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
if (m_parseSDF) {
TiXmlElement* pose = config->FirstChildElement("pose");
XMLElement* pose = config->FirstChildElement("pose");
if (0==pose)
{
link.m_linkTransformInWorld.setIdentity();
@@ -730,7 +739,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
</contact>
</audio_source>
#endif
TiXmlElement* ci = config->FirstChildElement("audio_source");
XMLElement* ci = config->FirstChildElement("audio_source");
if (ci)
{
link.m_audioSource.m_flags |= SDFAudioSource::SDFAudioSourceValid;
@@ -741,41 +750,41 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
link.m_audioSource.m_uri = fn;
} else
{
if (TiXmlElement* filename_xml = ci->FirstChildElement("uri"))
if (XMLElement* filename_xml = ci->FirstChildElement("uri"))
{
link.m_audioSource.m_uri = filename_xml->GetText();
}
}
if (TiXmlElement* pitch_xml = ci->FirstChildElement("pitch"))
if (XMLElement* pitch_xml = ci->FirstChildElement("pitch"))
{
link.m_audioSource.m_pitch = urdfLexicalCast<double>(pitch_xml->GetText());
}
if (TiXmlElement* gain_xml = ci->FirstChildElement("gain"))
if (XMLElement* gain_xml = ci->FirstChildElement("gain"))
{
link.m_audioSource.m_gain = urdfLexicalCast<double>(gain_xml->GetText());
}
if (TiXmlElement* attack_rate_xml = ci->FirstChildElement("attack_rate"))
if (XMLElement* attack_rate_xml = ci->FirstChildElement("attack_rate"))
{
link.m_audioSource.m_attackRate = urdfLexicalCast<double>(attack_rate_xml->GetText());
}
if (TiXmlElement* decay_rate_xml = ci->FirstChildElement("decay_rate"))
if (XMLElement* decay_rate_xml = ci->FirstChildElement("decay_rate"))
{
link.m_audioSource.m_decayRate = urdfLexicalCast<double>(decay_rate_xml->GetText());
}
if (TiXmlElement* sustain_level_xml = ci->FirstChildElement("sustain_level"))
if (XMLElement* sustain_level_xml = ci->FirstChildElement("sustain_level"))
{
link.m_audioSource.m_sustainLevel = urdfLexicalCast<double>(sustain_level_xml->GetText());
}
if (TiXmlElement* release_rate_xml = ci->FirstChildElement("release_rate"))
if (XMLElement* release_rate_xml = ci->FirstChildElement("release_rate"))
{
link.m_audioSource.m_releaseRate = urdfLexicalCast<double>(release_rate_xml->GetText());
}
if (TiXmlElement* loop_xml = ci->FirstChildElement("loop"))
if (XMLElement* loop_xml = ci->FirstChildElement("loop"))
{
std::string looptxt = loop_xml->GetText();
if (looptxt == "true")
@@ -783,7 +792,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
link.m_audioSource.m_flags |= SDFAudioSource::SDFAudioSourceLooping;
}
}
if (TiXmlElement* forceThreshold_xml = ci->FirstChildElement("collision_force_threshold"))
if (XMLElement* forceThreshold_xml = ci->FirstChildElement("collision_force_threshold"))
{
link.m_audioSource.m_collisionForceThreshold= urdfLexicalCast<double>(forceThreshold_xml->GetText());
}
@@ -794,11 +803,11 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
{
//optional 'contact' parameters
TiXmlElement* ci = config->FirstChildElement("contact");
XMLElement* ci = config->FirstChildElement("contact");
if (ci)
{
TiXmlElement *damping_xml = ci->FirstChildElement("inertia_scaling");
XMLElement *damping_xml = ci->FirstChildElement("inertia_scaling");
if (damping_xml)
{
if (m_parseSDF)
@@ -819,7 +828,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
}
{
TiXmlElement *friction_xml = ci->FirstChildElement("lateral_friction");
XMLElement *friction_xml = ci->FirstChildElement("lateral_friction");
if (friction_xml)
{
if (m_parseSDF)
@@ -839,7 +848,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
{
TiXmlElement *rolling_xml = ci->FirstChildElement("rolling_friction");
XMLElement *rolling_xml = ci->FirstChildElement("rolling_friction");
if (rolling_xml)
{
if (m_parseSDF)
@@ -862,7 +871,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
{
TiXmlElement *restitution_xml = ci->FirstChildElement("restitution");
XMLElement *restitution_xml = ci->FirstChildElement("restitution");
if (restitution_xml)
{
if (m_parseSDF)
@@ -886,7 +895,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
{
TiXmlElement *spinning_xml = ci->FirstChildElement("spinning_friction");
XMLElement *spinning_xml = ci->FirstChildElement("spinning_friction");
if (spinning_xml)
{
if (m_parseSDF)
@@ -908,7 +917,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
}
{
TiXmlElement *friction_anchor = ci->FirstChildElement("friction_anchor");
XMLElement *friction_anchor = ci->FirstChildElement("friction_anchor");
if (friction_anchor)
{
link.m_contactInfo.m_flags |= URDF_CONTACT_HAS_FRICTION_ANCHOR;
@@ -916,7 +925,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
{
TiXmlElement *stiffness_xml = ci->FirstChildElement("stiffness");
XMLElement *stiffness_xml = ci->FirstChildElement("stiffness");
if (stiffness_xml)
{
if (m_parseSDF)
@@ -939,7 +948,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
{
TiXmlElement *damping_xml = ci->FirstChildElement("damping");
XMLElement *damping_xml = ci->FirstChildElement("damping");
if (damping_xml)
{
if (m_parseSDF)
@@ -964,7 +973,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
// Inertial (optional)
TiXmlElement *i = config->FirstChildElement("inertial");
XMLElement *i = config->FirstChildElement("inertial");
if (i)
{
if (!parseInertia(link.m_inertia, i,logger))
@@ -997,7 +1006,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
}
// Multiple Visuals (optional)
for (TiXmlElement* vis_xml = config->FirstChildElement("visual"); vis_xml; vis_xml = vis_xml->NextSiblingElement("visual"))
for (XMLElement* vis_xml = config->FirstChildElement("visual"); vis_xml; vis_xml = vis_xml->NextSiblingElement("visual"))
{
UrdfVisual visual;
visual.m_sourceFileLocation = sourceFileLocation(vis_xml);
@@ -1017,7 +1026,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
// Multiple Collisions (optional)
for (TiXmlElement* col_xml = config->FirstChildElement("collision"); col_xml; col_xml = col_xml->NextSiblingElement("collision"))
for (XMLElement* col_xml = config->FirstChildElement("collision"); col_xml; col_xml = col_xml->NextSiblingElement("collision"))
{
UrdfCollision col;
col.m_sourceFileLocation = sourceFileLocation(col_xml);
@@ -1036,7 +1045,7 @@ bool UrdfParser::parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *confi
return true;
}
bool UrdfParser::parseJointLimits(UrdfJoint& joint, TiXmlElement* config, ErrorLogger* logger)
bool UrdfParser::parseJointLimits(UrdfJoint& joint, XMLElement* config, ErrorLogger* logger)
{
joint.m_lowerLimit = 0.f;
joint.m_upperLimit = -1.f;
@@ -1047,22 +1056,22 @@ bool UrdfParser::parseJointLimits(UrdfJoint& joint, TiXmlElement* config, ErrorL
if (m_parseSDF)
{
TiXmlElement *lower_xml = config->FirstChildElement("lower");
XMLElement *lower_xml = config->FirstChildElement("lower");
if (lower_xml) {
joint.m_lowerLimit = urdfLexicalCast<double>(lower_xml->GetText());
}
TiXmlElement *upper_xml = config->FirstChildElement("upper");
XMLElement *upper_xml = config->FirstChildElement("upper");
if (upper_xml) {
joint.m_upperLimit = urdfLexicalCast<double>(upper_xml->GetText());
}
TiXmlElement *effort_xml = config->FirstChildElement("effort");
XMLElement *effort_xml = config->FirstChildElement("effort");
if (effort_xml) {
joint.m_effortLimit = urdfLexicalCast<double>(effort_xml->GetText());
}
TiXmlElement *velocity_xml = config->FirstChildElement("velocity");
XMLElement *velocity_xml = config->FirstChildElement("velocity");
if (velocity_xml) {
joint.m_velocityLimit = urdfLexicalCast<double>(velocity_xml->GetText());
}
@@ -1105,18 +1114,18 @@ bool UrdfParser::parseJointLimits(UrdfJoint& joint, TiXmlElement* config, ErrorL
return true;
}
bool UrdfParser::parseJointDynamics(UrdfJoint& joint, TiXmlElement* config, ErrorLogger* logger)
bool UrdfParser::parseJointDynamics(UrdfJoint& joint, XMLElement* config, ErrorLogger* logger)
{
joint.m_jointDamping = 0;
joint.m_jointFriction = 0;
if (m_parseSDF) {
TiXmlElement *damping_xml = config->FirstChildElement("damping");
XMLElement *damping_xml = config->FirstChildElement("damping");
if (damping_xml) {
joint.m_jointDamping = urdfLexicalCast<double>(damping_xml->GetText());
}
TiXmlElement *friction_xml = config->FirstChildElement("friction");
XMLElement *friction_xml = config->FirstChildElement("friction");
if (friction_xml) {
joint.m_jointFriction = urdfLexicalCast<double>(friction_xml->GetText());
}
@@ -1153,7 +1162,7 @@ bool UrdfParser::parseJointDynamics(UrdfJoint& joint, TiXmlElement* config, Erro
return true;
}
bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger* logger)
bool UrdfParser::parseJoint(UrdfJoint& joint, XMLElement *config, ErrorLogger* logger)
{
@@ -1168,7 +1177,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
joint.m_parentLinkToJointTransform.setIdentity();
// Get transform from Parent Link to Joint Frame
TiXmlElement *origin_xml = config->FirstChildElement("origin");
XMLElement *origin_xml = config->FirstChildElement("origin");
if (origin_xml)
{
if (!parseTransform(joint.m_parentLinkToJointTransform, origin_xml,logger))
@@ -1180,7 +1189,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
}
// Get Parent Link
TiXmlElement *parent_xml = config->FirstChildElement("parent");
XMLElement *parent_xml = config->FirstChildElement("parent");
if (parent_xml)
{
if (m_parseSDF)
@@ -1204,7 +1213,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
}
// Get Child Link
TiXmlElement *child_xml = config->FirstChildElement("child");
XMLElement *child_xml = config->FirstChildElement("child");
if (child_xml)
{
if (m_parseSDF)
@@ -1263,14 +1272,14 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
if (joint.m_type != URDFFloatingJoint && joint.m_type != URDFFixedJoint)
{
// axis
TiXmlElement *axis_xml = config->FirstChildElement("axis");
XMLElement *axis_xml = config->FirstChildElement("axis");
if (!axis_xml){
logger->reportWarning("urdfdom: no axis elemement for Joint, defaulting to (1,0,0) axis");
logger->reportWarning(joint.m_name.c_str());
joint.m_localJointAxis.setValue(1,0,0);
}
else{
TiXmlElement *xyz_xml = axis_xml->FirstChildElement("xyz");
XMLElement *xyz_xml = axis_xml->FirstChildElement("xyz");
if (xyz_xml) {
if (!parseVector3(joint.m_localJointAxis,std::string(xyz_xml->GetText()),logger))
{
@@ -1282,7 +1291,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
}
}
TiXmlElement *limit_xml = axis_xml->FirstChildElement("limit");
XMLElement *limit_xml = axis_xml->FirstChildElement("limit");
if (limit_xml)
{
if (joint.m_type != URDFContinuousJoint)
@@ -1308,7 +1317,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
return false;
}
TiXmlElement *prop_xml = axis_xml->FirstChildElement("dynamics");
XMLElement *prop_xml = axis_xml->FirstChildElement("dynamics");
if (prop_xml)
{
if (!parseJointDynamics(joint, prop_xml,logger))
@@ -1327,7 +1336,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
if (joint.m_type != URDFFloatingJoint && joint.m_type != URDFFixedJoint)
{
// axis
TiXmlElement *axis_xml = config->FirstChildElement("axis");
XMLElement *axis_xml = config->FirstChildElement("axis");
if (!axis_xml){
logger->reportWarning("urdfdom: no axis elemement for Joint, defaulting to (1,0,0) axis");
logger->reportWarning(joint.m_name.c_str());
@@ -1349,7 +1358,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
}
// Get limit
TiXmlElement *limit_xml = config->FirstChildElement("limit");
XMLElement *limit_xml = config->FirstChildElement("limit");
if (limit_xml)
{
if (!parseJointLimits(joint, limit_xml,logger))
@@ -1376,7 +1385,7 @@ bool UrdfParser::parseJoint(UrdfJoint& joint, TiXmlElement *config, ErrorLogger*
joint.m_jointFriction = 0;
// Get Dynamics
TiXmlElement *prop_xml = config->FirstChildElement("dynamics");
XMLElement *prop_xml = config->FirstChildElement("dynamics");
if (prop_xml)
{
@@ -1491,16 +1500,16 @@ bool UrdfParser::initTreeAndRoot(UrdfModel& model, ErrorLogger* logger)
bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceFixedBase)
{
TiXmlDocument xml_doc;
XMLDocument xml_doc;
xml_doc.Parse(urdfText);
if (xml_doc.Error())
{
logger->reportError(xml_doc.ErrorDesc());
logger->reportError(xml_doc.ErrorStr());
xml_doc.ClearError();
return false;
}
TiXmlElement *robot_xml = xml_doc.FirstChildElement("robot");
XMLElement *robot_xml = xml_doc.FirstChildElement("robot");
if (!robot_xml)
{
logger->reportError("expected a robot element");
@@ -1519,7 +1528,7 @@ bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceF
// Get all Material elements
for (TiXmlElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
for (XMLElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
{
UrdfMaterial* material = new UrdfMaterial;
@@ -1543,7 +1552,7 @@ bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceF
// logger->printMessage(msg);
for (TiXmlElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
for (XMLElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
{
UrdfLink* link = new UrdfLink;
@@ -1592,7 +1601,7 @@ bool UrdfParser::loadUrdf(const char* urdfText, ErrorLogger* logger, bool forceF
}
// Get all Joint elements
for (TiXmlElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
for (XMLElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
{
UrdfJoint* joint = new UrdfJoint;
@@ -1651,16 +1660,16 @@ void UrdfParser::activateModel(int modelIndex)
bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
{
TiXmlDocument xml_doc;
XMLDocument xml_doc;
xml_doc.Parse(sdfText);
if (xml_doc.Error())
{
logger->reportError(xml_doc.ErrorDesc());
logger->reportError(xml_doc.ErrorStr());
xml_doc.ClearError();
return false;
}
TiXmlElement *sdf_xml = xml_doc.FirstChildElement("sdf");
XMLElement *sdf_xml = xml_doc.FirstChildElement("sdf");
if (!sdf_xml)
{
logger->reportError("expected an sdf element");
@@ -1668,9 +1677,9 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
}
//apparently, SDF doesn't require a "world" element, optional? URDF does.
TiXmlElement *world_xml = sdf_xml->FirstChildElement("world");
XMLElement *world_xml = sdf_xml->FirstChildElement("world");
TiXmlElement* robot_xml = 0;
XMLElement* robot_xml = 0;
if (!world_xml)
{
@@ -1687,7 +1696,7 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
UrdfModel* localModel = new UrdfModel;
m_tmpModels.push_back(localModel);
TiXmlElement* stat = robot_xml->FirstChildElement("static");
XMLElement* stat = robot_xml->FirstChildElement("static");
if (0!=stat)
{
int val = int(atof(stat->GetText()));
@@ -1707,7 +1716,7 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
}
localModel->m_name = name;
TiXmlElement* pose_xml = robot_xml->FirstChildElement("pose");
XMLElement* pose_xml = robot_xml->FirstChildElement("pose");
if (0==pose_xml)
{
localModel->m_rootTransformInWorld.setIdentity();
@@ -1718,7 +1727,7 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
}
// Get all Material elements
for (TiXmlElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
for (XMLElement* material_xml = robot_xml->FirstChildElement("material"); material_xml; material_xml = material_xml->NextSiblingElement("material"))
{
UrdfMaterial* material = new UrdfMaterial;
@@ -1742,7 +1751,7 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
// logger->printMessage(msg);
for (TiXmlElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
for (XMLElement* link_xml = robot_xml->FirstChildElement("link"); link_xml; link_xml = link_xml->NextSiblingElement("link"))
{
UrdfLink* link = new UrdfLink;
@@ -1791,7 +1800,7 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
}
// Get all Joint elements
for (TiXmlElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
for (XMLElement* joint_xml = robot_xml->FirstChildElement("joint"); joint_xml; joint_xml = joint_xml->NextSiblingElement("joint"))
{
UrdfJoint* joint = new UrdfJoint;
@@ -1828,7 +1837,7 @@ bool UrdfParser::loadSDF(const char* sdfText, ErrorLogger* logger)
return true;
}
std::string UrdfParser::sourceFileLocation(TiXmlElement* e)
std::string UrdfParser::sourceFileLocation(XMLElement* e)
{
#if 0
//no C++11 etc, no snprintf
@@ -1838,7 +1847,7 @@ std::string UrdfParser::sourceFileLocation(TiXmlElement* e)
return buf;
#else
char row[1024];
sprintf(row,"%d",e->Row());
sprintf(row,"%d",e->GetLineNum());
std::string str = m_urdf2Model.m_sourceFile.c_str() + std::string(":") + std::string(row);
return str;
#endif

View File

@@ -54,7 +54,8 @@ enum UrdfGeomTypes
URDF_GEOM_CYLINDER,
URDF_GEOM_MESH,
URDF_GEOM_PLANE,
URDF_GEOM_CAPSULE, //non-standard URDF?
URDF_GEOM_CAPSULE, //non-standard URDF
URDF_GEOM_CDF,//signed-distance-field, non-standard URDF
URDF_GEOM_UNKNOWN,
};
@@ -79,6 +80,8 @@ struct UrdfGeometry
FILE_STL =1,
FILE_COLLADA =2,
FILE_OBJ =3,
FILE_CDF = 4,
};
int m_meshFileType;
std::string m_meshFileName;
@@ -240,6 +243,11 @@ struct UrdfModel
}
};
namespace tinyxml2
{
class XMLElement;
};
class UrdfParser
{
protected:
@@ -252,17 +260,17 @@ protected:
int m_activeSdfModel;
btScalar m_urdfScaling;
bool parseTransform(btTransform& tr, class TiXmlElement* xml, ErrorLogger* logger, bool parseSDF = false);
bool parseInertia(UrdfInertia& inertia, class TiXmlElement* config, ErrorLogger* logger);
bool parseGeometry(UrdfGeometry& geom, class TiXmlElement* g, ErrorLogger* logger);
bool parseVisual(UrdfModel& model, UrdfVisual& visual, class TiXmlElement* config, ErrorLogger* logger);
bool parseCollision(UrdfCollision& collision, class TiXmlElement* config, ErrorLogger* logger);
bool parseTransform(btTransform& tr, tinyxml2::XMLElement* xml, ErrorLogger* logger, bool parseSDF = false);
bool parseInertia(UrdfInertia& inertia, tinyxml2::XMLElement* config, ErrorLogger* logger);
bool parseGeometry(UrdfGeometry& geom, tinyxml2::XMLElement* g, ErrorLogger* logger);
bool parseVisual(UrdfModel& model, UrdfVisual& visual, tinyxml2::XMLElement* config, ErrorLogger* logger);
bool parseCollision(UrdfCollision& collision, tinyxml2::XMLElement* config, ErrorLogger* logger);
bool initTreeAndRoot(UrdfModel& model, ErrorLogger* logger);
bool parseMaterial(UrdfMaterial& material, class TiXmlElement *config, ErrorLogger* logger);
bool parseJointLimits(UrdfJoint& joint, TiXmlElement* config, ErrorLogger* logger);
bool parseJointDynamics(UrdfJoint& joint, TiXmlElement* config, ErrorLogger* logger);
bool parseJoint(UrdfJoint& link, TiXmlElement *config, ErrorLogger* logger);
bool parseLink(UrdfModel& model, UrdfLink& link, TiXmlElement *config, ErrorLogger* logger);
bool parseMaterial(UrdfMaterial& material, tinyxml2::XMLElement *config, ErrorLogger* logger);
bool parseJointLimits(UrdfJoint& joint, tinyxml2::XMLElement* config, ErrorLogger* logger);
bool parseJointDynamics(UrdfJoint& joint, tinyxml2::XMLElement* config, ErrorLogger* logger);
bool parseJoint(UrdfJoint& joint, tinyxml2::XMLElement *config, ErrorLogger* logger);
bool parseLink(UrdfModel& model, UrdfLink& link, tinyxml2::XMLElement *config, ErrorLogger* logger);
public:
@@ -333,7 +341,7 @@ public:
return m_urdf2Model;
}
std::string sourceFileLocation(TiXmlElement* e);
std::string sourceFileLocation(tinyxml2::XMLElement* e);
void setSourceFile(const std::string& sourceFile)
{

View File

@@ -29,17 +29,17 @@ class btCollisionShape;
#include "BulletCollision/CollisionDispatch/btCollisionDispatcherMt.h"
#include "BulletDynamics/Dynamics/btSimulationIslandManagerMt.h" // for setSplitIslands()
#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorldMt.h"
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolverMt.h"
#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
#include "BulletDynamics/ConstraintSolver/btNNCGConstraintSolver.h"
#include "BulletDynamics/MLCPSolvers/btMLCPSolver.h"
#include "BulletDynamics/MLCPSolvers/btSolveProjectedGaussSeidel.h"
#include "BulletDynamics/MLCPSolvers/btDantzigSolver.h"
#include "BulletDynamics/MLCPSolvers/btLemkeSolver.h"
#include "../MultiThreading/btTaskScheduler.h"
static int gNumIslands = 0;
bool gAllowNestedParallelForLoops = false;
class Profiler
{
@@ -52,6 +52,10 @@ public:
kRecordPredictUnconstrainedMotion,
kRecordCreatePredictiveContacts,
kRecordIntegrateTransforms,
kRecordSolverTotal,
kRecordSolverSetup,
kRecordSolverIterations,
kRecordSolverFinish,
kRecordCount
};
@@ -139,6 +143,41 @@ static void profileEndCallback( btDynamicsWorld *world, btScalar timeStep )
}
class MySequentialImpulseConstraintSolverMt : public btSequentialImpulseConstraintSolverMt
{
typedef btSequentialImpulseConstraintSolverMt ParentClass;
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
MySequentialImpulseConstraintSolverMt() {}
// for profiling
virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) BT_OVERRIDE
{
ProfileHelper prof(Profiler::kRecordSolverSetup);
btScalar ret = ParentClass::solveGroupCacheFriendlySetup(bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer );
return ret;
}
virtual btScalar solveGroupCacheFriendlyIterations( btCollisionObject** bodies, int numBodies, btPersistentManifold** manifoldPtr, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& infoGlobal, btIDebugDraw* debugDrawer ) BT_OVERRIDE
{
ProfileHelper prof(Profiler::kRecordSolverIterations);
btScalar ret = ParentClass::solveGroupCacheFriendlyIterations(bodies, numBodies, manifoldPtr, numManifolds, constraints, numConstraints, infoGlobal, debugDrawer );
return ret;
}
virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies,int numBodies,const btContactSolverInfo& infoGlobal) BT_OVERRIDE
{
ProfileHelper prof(Profiler::kRecordSolverFinish);
btScalar ret = ParentClass::solveGroupCacheFriendlyFinish(bodies, numBodies, infoGlobal);
return ret;
}
virtual btScalar solveGroup(btCollisionObject** bodies, int numBodies, btPersistentManifold** manifold, int numManifolds, btTypedConstraint** constraints, int numConstraints, const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btDispatcher* dispatcher) BT_OVERRIDE
{
ProfileHelper prof(Profiler::kRecordSolverTotal);
btScalar ret = ParentClass::solveGroup(bodies, numBodies, manifold, numManifolds, constraints, numConstraints, info, debugDrawer, dispatcher);
return ret;
}
};
///
/// MyCollisionDispatcher -- subclassed for profiling purposes
///
@@ -161,11 +200,11 @@ public:
///
/// myParallelIslandDispatch -- wrap default parallel dispatch for profiling and to get the number of simulation islands
//
void myParallelIslandDispatch( btAlignedObjectArray<btSimulationIslandManagerMt::Island*>* islandsPtr, btSimulationIslandManagerMt::IslandCallback* callback )
void myParallelIslandDispatch( btAlignedObjectArray<btSimulationIslandManagerMt::Island*>* islandsPtr, const btSimulationIslandManagerMt::SolverParams& solverParams)
{
ProfileHelper prof( Profiler::kRecordDispatchIslands );
gNumIslands = islandsPtr->size();
btSimulationIslandManagerMt::parallelIslandDispatch( islandsPtr, callback );
btSimulationIslandManagerMt::parallelIslandDispatch( islandsPtr, solverParams );
}
@@ -200,9 +239,10 @@ public:
MyDiscreteDynamicsWorld( btDispatcher* dispatcher,
btBroadphaseInterface* pairCache,
btConstraintSolverPoolMt* constraintSolver,
btSequentialImpulseConstraintSolverMt* constraintSolverMt,
btCollisionConfiguration* collisionConfiguration
) :
btDiscreteDynamicsWorldMt( dispatcher, pairCache, constraintSolver, collisionConfiguration )
btDiscreteDynamicsWorldMt( dispatcher, pairCache, constraintSolver, constraintSolverMt, collisionConfiguration )
{
btSimulationIslandManagerMt* islandMgr = static_cast<btSimulationIslandManagerMt*>( m_islandManager );
islandMgr->setIslandDispatchFunction( myParallelIslandDispatch );
@@ -218,6 +258,8 @@ btConstraintSolver* createSolverByType( SolverType t )
{
case SOLVER_TYPE_SEQUENTIAL_IMPULSE:
return new btSequentialImpulseConstraintSolver();
case SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT:
return new MySequentialImpulseConstraintSolverMt();
case SOLVER_TYPE_NNCG:
return new btNNCGConstraintSolver();
case SOLVER_TYPE_MLCP_PGS:
@@ -253,7 +295,7 @@ public:
{
addTaskScheduler( btGetSequentialTaskScheduler() );
#if BT_THREADSAFE
if ( btITaskScheduler* ts = createDefaultTaskScheduler() )
if ( btITaskScheduler* ts = btCreateDefaultTaskScheduler() )
{
m_allocatedTaskSchedulers.push_back( ts );
addTaskScheduler( ts );
@@ -306,11 +348,12 @@ static btTaskSchedulerManager gTaskSchedulerMgr;
#if BT_THREADSAFE
static bool gMultithreadedWorld = true;
static bool gDisplayProfileInfo = true;
static SolverType gSolverType = SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT;
#else
static bool gMultithreadedWorld = false;
static bool gDisplayProfileInfo = false;
#endif
static SolverType gSolverType = SOLVER_TYPE_SEQUENTIAL_IMPULSE;
#endif
static int gSolverMode = SOLVER_SIMD |
SOLVER_USE_WARMSTARTING |
// SOLVER_RANDMIZE_ORDER |
@@ -318,9 +361,11 @@ static int gSolverMode = SOLVER_SIMD |
// SOLVER_USE_2_FRICTION_DIRECTIONS |
0;
static btScalar gSliderSolverIterations = 10.0f; // should be int
static btScalar gSliderNumThreads = 1.0f; // should be int
static btScalar gSliderIslandBatchingThreshold = 0.0f; // should be int
static btScalar gSliderMinBatchSize = btScalar(btSequentialImpulseConstraintSolverMt::s_minBatchSize); // should be int
static btScalar gSliderMaxBatchSize = btScalar(btSequentialImpulseConstraintSolverMt::s_maxBatchSize); // should be int
static btScalar gSliderLeastSquaresResidualThreshold = 0.0f;
////////////////////////////////////
CommonRigidBodyMTBase::CommonRigidBodyMTBase( struct GUIHelperInterface* helper )
@@ -419,6 +464,23 @@ void setTaskSchedulerComboBoxCallback(int combobox, const char* item, void* user
}
void setBatchingMethodComboBoxCallback(int combobox, const char* item, void* userPointer)
{
#if BT_THREADSAFE
const char** items = static_cast<const char**>( userPointer );
for ( int i = 0; i < btBatchedConstraints::BATCHING_METHOD_COUNT; ++i )
{
if ( strcmp( item, items[ i ] ) == 0 )
{
// change the task scheduler
btSequentialImpulseConstraintSolverMt::s_contactBatchingMethod = static_cast<btBatchedConstraints::BatchingMethod>( i );
break;
}
}
#endif // #if BT_THREADSAFE
}
static void setThreadCountCallback(float val, void* userPtr)
{
#if BT_THREADSAFE
@@ -435,13 +497,43 @@ static void setSolverIterationCountCallback(float val, void* userPtr)
}
}
static void setLargeIslandManifoldCountCallback( float val, void* userPtr )
{
btSequentialImpulseConstraintSolverMt::s_minimumContactManifoldsForBatching = int( gSliderIslandBatchingThreshold );
}
static void setMinBatchSizeCallback( float val, void* userPtr )
{
gSliderMaxBatchSize = (std::max)(gSliderMinBatchSize, gSliderMaxBatchSize);
btSequentialImpulseConstraintSolverMt::s_minBatchSize = int(gSliderMinBatchSize);
btSequentialImpulseConstraintSolverMt::s_maxBatchSize = int(gSliderMaxBatchSize);
}
static void setMaxBatchSizeCallback( float val, void* userPtr )
{
gSliderMinBatchSize = (std::min)(gSliderMinBatchSize, gSliderMaxBatchSize);
btSequentialImpulseConstraintSolverMt::s_minBatchSize = int(gSliderMinBatchSize);
btSequentialImpulseConstraintSolverMt::s_maxBatchSize = int(gSliderMaxBatchSize);
}
static void setLeastSquaresResidualThresholdCallback( float val, void* userPtr )
{
if (btDiscreteDynamicsWorld* world = reinterpret_cast<btDiscreteDynamicsWorld*>(userPtr))
{
world->getSolverInfo().m_leastSquaresResidualThreshold = gSliderLeastSquaresResidualThreshold;
}
}
void CommonRigidBodyMTBase::createEmptyDynamicsWorld()
{
gNumIslands = 0;
m_solverType = gSolverType;
#if BT_THREADSAFE && (BT_USE_OPENMP || BT_USE_PPL || BT_USE_TBB)
#if BT_THREADSAFE
btAssert( btGetTaskScheduler() != NULL );
m_multithreadCapable = true;
if (NULL != btGetTaskScheduler() && gTaskSchedulerMgr.getNumTaskSchedulers() > 1)
{
m_multithreadCapable = true;
}
#endif
if ( gMultithreadedWorld )
{
@@ -457,16 +549,28 @@ void CommonRigidBodyMTBase::createEmptyDynamicsWorld()
btConstraintSolverPoolMt* solverPool;
{
SolverType poolSolverType = m_solverType;
if (poolSolverType == SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT)
{
// pool solvers shouldn't be parallel solvers, we don't allow that kind of
// nested parallelism because of performance issues
poolSolverType = SOLVER_TYPE_SEQUENTIAL_IMPULSE;
}
btConstraintSolver* solvers[ BT_MAX_THREAD_COUNT ];
int maxThreadCount = BT_MAX_THREAD_COUNT;
for ( int i = 0; i < maxThreadCount; ++i )
{
solvers[ i ] = createSolverByType( m_solverType );
solvers[ i ] = createSolverByType( poolSolverType );
}
solverPool = new btConstraintSolverPoolMt( solvers, maxThreadCount );
m_solver = solverPool;
}
btDiscreteDynamicsWorld* world = new MyDiscreteDynamicsWorld( m_dispatcher, m_broadphase, solverPool, m_collisionConfiguration );
btSequentialImpulseConstraintSolverMt* solverMt = NULL;
if ( m_solverType == SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT )
{
solverMt = new MySequentialImpulseConstraintSolverMt();
}
btDiscreteDynamicsWorld* world = new MyDiscreteDynamicsWorld( m_dispatcher, m_broadphase, solverPool, solverMt, m_collisionConfiguration );
m_dynamicsWorld = world;
m_multithreadedWorld = true;
btAssert( btGetTaskScheduler() != NULL );
@@ -486,7 +590,14 @@ void CommonRigidBodyMTBase::createEmptyDynamicsWorld()
m_broadphase = new btDbvtBroadphase();
m_solver = createSolverByType( m_solverType );
SolverType solverType = m_solverType;
if ( solverType == SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT )
{
// using the parallel solver with the single-threaded world works, but is
// disabled here to avoid confusion
solverType = SOLVER_TYPE_SEQUENTIAL_IMPULSE;
}
m_solver = createSolverByType( solverType );
m_dynamicsWorld = new btDiscreteDynamicsWorld( m_dispatcher, m_broadphase, m_solver, m_collisionConfiguration );
}
@@ -494,6 +605,7 @@ void CommonRigidBodyMTBase::createEmptyDynamicsWorld()
m_dynamicsWorld->setInternalTickCallback( profileEndCallback, NULL, false );
m_dynamicsWorld->setGravity( btVector3( 0, -10, 0 ) );
m_dynamicsWorld->getSolverInfo().m_solverMode = gSolverMode;
m_dynamicsWorld->getSolverInfo().m_numIterations = btMax(1, int(gSliderSolverIterations));
createDefaultParameters();
}
@@ -504,16 +616,18 @@ void CommonRigidBodyMTBase::createDefaultParameters()
{
// create a button to toggle multithreaded world
ButtonParams button( "Multithreaded world enable", 0, true );
button.m_initialState = gMultithreadedWorld;
button.m_userPointer = &gMultithreadedWorld;
bool* ptr = &gMultithreadedWorld;
button.m_initialState = *ptr;
button.m_userPointer = ptr;
button.m_callback = boolPtrButtonCallback;
m_guiHelper->getParameterInterface()->registerButtonParameter( button );
}
{
// create a button to toggle profile printing
ButtonParams button( "Display solver info", 0, true );
button.m_initialState = gDisplayProfileInfo;
button.m_userPointer = &gDisplayProfileInfo;
bool* ptr = &gDisplayProfileInfo;
button.m_initialState = *ptr;
button.m_userPointer = ptr;
button.m_callback = boolPtrButtonCallback;
m_guiHelper->getParameterInterface()->registerButtonParameter( button );
}
@@ -544,6 +658,16 @@ void CommonRigidBodyMTBase::createDefaultParameters()
slider.m_clampToIntegers = true;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
}
{
// a slider for the solver leastSquaresResidualThreshold (used to run fewer solver iterations when convergence is good)
SliderParams slider( "Solver residual thresh", &gSliderLeastSquaresResidualThreshold );
slider.m_minVal = 0.0f;
slider.m_maxVal = 0.25f;
slider.m_callback = setLeastSquaresResidualThresholdCallback;
slider.m_userPointer = m_dynamicsWorld;
slider.m_clampToIntegers = false;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
}
{
ButtonParams button( "Solver use SIMD", 0, true );
button.m_buttonId = SOLVER_SIMD;
@@ -618,20 +742,86 @@ void CommonRigidBodyMTBase::createDefaultParameters()
m_guiHelper->getParameterInterface()->registerComboBox( comboParams );
}
{
// create a slider to set the number of threads to use
int numThreads = btGetTaskScheduler()->getNumThreads();
// if slider has not been set yet (by another demo),
if ( gSliderNumThreads <= 1.0f )
{
// create a slider to set the number of threads to use
int numThreads = btGetTaskScheduler()->getNumThreads();
gSliderNumThreads = float( numThreads );
}
int maxNumThreads = btGetTaskScheduler()->getMaxNumThreads();
SliderParams slider("Thread count", &gSliderNumThreads);
slider.m_minVal = 1.0f;
slider.m_maxVal = float( BT_MAX_THREAD_COUNT );
slider.m_maxVal = float( maxNumThreads );
slider.m_callback = setThreadCountCallback;
slider.m_clampToIntegers = true;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
}
{
// a slider for the number of manifolds an island needs to be too large for parallel dispatch
if (gSliderIslandBatchingThreshold < 1.0)
{
gSliderIslandBatchingThreshold = float(btSequentialImpulseConstraintSolverMt::s_minimumContactManifoldsForBatching);
}
SliderParams slider( "IslandBatchThresh", &gSliderIslandBatchingThreshold );
slider.m_minVal = 1.0f;
slider.m_maxVal = 2000.0f;
slider.m_callback = setLargeIslandManifoldCountCallback;
slider.m_userPointer = NULL;
slider.m_clampToIntegers = true;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
}
{
// create a combo box for selecting the batching method
static const char* sBatchingMethodComboBoxItems[ btBatchedConstraints::BATCHING_METHOD_COUNT ];
{
sBatchingMethodComboBoxItems[ btBatchedConstraints::BATCHING_METHOD_SPATIAL_GRID_2D ] = "Batching: 2D Grid";
sBatchingMethodComboBoxItems[ btBatchedConstraints::BATCHING_METHOD_SPATIAL_GRID_3D ] = "Batching: 3D Grid";
};
ComboBoxParams comboParams;
comboParams.m_userPointer = sBatchingMethodComboBoxItems;
comboParams.m_numItems = btBatchedConstraints::BATCHING_METHOD_COUNT;
comboParams.m_startItem = static_cast<int>(btSequentialImpulseConstraintSolverMt::s_contactBatchingMethod);
comboParams.m_items = sBatchingMethodComboBoxItems;
comboParams.m_callback = setBatchingMethodComboBoxCallback;
m_guiHelper->getParameterInterface()->registerComboBox( comboParams );
}
{
// a slider for the sequentialImpulseConstraintSolverMt min batch size (when batching)
SliderParams slider( "Min batch size", &gSliderMinBatchSize );
slider.m_minVal = 1.0f;
slider.m_maxVal = 1000.0f;
slider.m_callback = setMinBatchSizeCallback;
slider.m_userPointer = NULL;
slider.m_clampToIntegers = true;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
}
{
// a slider for the sequentialImpulseConstraintSolverMt max batch size (when batching)
SliderParams slider( "Max batch size", &gSliderMaxBatchSize );
slider.m_minVal = 1.0f;
slider.m_maxVal = 1000.0f;
slider.m_callback = setMaxBatchSizeCallback;
slider.m_userPointer = NULL;
slider.m_clampToIntegers = true;
m_guiHelper->getParameterInterface()->registerSliderFloatParameter( slider );
}
{
// create a button to toggle debug drawing of batching visualization
ButtonParams button( "Visualize batching", 0, true );
bool* ptr = &btBatchedConstraints::s_debugDrawBatches;
button.m_initialState = *ptr;
button.m_userPointer = ptr;
button.m_callback = boolPtrButtonCallback;
m_guiHelper->getParameterInterface()->registerButtonParameter( button );
}
{
ButtonParams button( "Allow Nested ParallelFor", 0, true );
button.m_initialState = btSequentialImpulseConstraintSolverMt::s_allowNestedParallelForLoops;
button.m_userPointer = &btSequentialImpulseConstraintSolverMt::s_allowNestedParallelForLoops;
button.m_callback = boolPtrButtonCallback;
m_guiHelper->getParameterInterface()->registerButtonParameter( button );
}
#endif // #if BT_THREADSAFE
}
}
@@ -643,6 +833,7 @@ void CommonRigidBodyMTBase::drawScreenText()
int xCoord = 400;
int yCoord = 30;
int yStep = 30;
int indent = 30;
if (m_solverType != gSolverType)
{
sprintf( msg, "restart example to change solver type" );
@@ -721,6 +912,34 @@ void CommonRigidBodyMTBase::drawScreenText()
m_guiHelper->getAppInterface()->drawText( msg, xCoord, yCoord, 0.4f );
yCoord += yStep;
sprintf( msg,
"SolverTotal %5.3f ms",
gProfiler.getAverageTime( Profiler::kRecordSolverTotal )*0.001f
);
m_guiHelper->getAppInterface()->drawText( msg, xCoord, yCoord, 0.4f );
yCoord += yStep;
sprintf( msg,
"SolverSetup %5.3f ms",
gProfiler.getAverageTime( Profiler::kRecordSolverSetup )*0.001f
);
m_guiHelper->getAppInterface()->drawText( msg, xCoord + indent, yCoord, 0.4f );
yCoord += yStep;
sprintf( msg,
"SolverIterations %5.3f ms",
gProfiler.getAverageTime( Profiler::kRecordSolverIterations )*0.001f
);
m_guiHelper->getAppInterface()->drawText( msg, xCoord + indent, yCoord, 0.4f );
yCoord += yStep;
sprintf( msg,
"SolverFinish %5.3f ms",
gProfiler.getAverageTime( Profiler::kRecordSolverFinish )*0.001f
);
m_guiHelper->getAppInterface()->drawText( msg, xCoord + indent, yCoord, 0.4f );
yCoord += yStep;
sprintf( msg,
"PredictUnconstrainedMotion %5.3f ms",
gProfiler.getAverageTime( Profiler::kRecordPredictUnconstrainedMotion )*0.001f

View File

@@ -14,6 +14,7 @@
enum SolverType
{
SOLVER_TYPE_SEQUENTIAL_IMPULSE,
SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT,
SOLVER_TYPE_NNCG,
SOLVER_TYPE_MLCP_PGS,
SOLVER_TYPE_MLCP_DANTZIG,
@@ -27,6 +28,7 @@ inline const char* getSolverTypeName( SolverType t )
switch (t)
{
case SOLVER_TYPE_SEQUENTIAL_IMPULSE: return "SequentialImpulse";
case SOLVER_TYPE_SEQUENTIAL_IMPULSE_MT: return "SequentialImpulseMt";
case SOLVER_TYPE_NNCG: return "NNCG";
case SOLVER_TYPE_MLCP_PGS: return "MLCP ProjectedGaussSeidel";
case SOLVER_TYPE_MLCP_DANTZIG: return "MLCP Dantzig";

View File

@@ -25,10 +25,10 @@ subject to the following restrictions:
static btScalar gSliderStackRows = 8.0f;
static btScalar gSliderStackColumns = 6.0f;
static btScalar gSliderStackHeight = 10.0f;
static btScalar gSliderStackWidth = 1.0f;
static btScalar gSliderStackRows = 1.0f;
static btScalar gSliderStackColumns = 1.0f;
static btScalar gSliderStackHeight = 15.0f;
static btScalar gSliderStackWidth = 8.0f;
static btScalar gSliderGroundHorizontalAmplitude = 0.0f;
static btScalar gSliderGroundVerticalAmplitude = 0.0f;
static btScalar gSliderGroundTilt = 0.0f;
@@ -75,6 +75,21 @@ public:
btScalar tilt = gSliderGroundTilt * SIMD_2_PI / 360.0f;
return btQuaternion( btVector3( 1.0f, 0.0f, 0.0f ), tilt );
}
struct TestSumBody : public btIParallelSumBody
{
virtual btScalar sumLoop( int iBegin, int iEnd ) const BT_OVERRIDE
{
btScalar sum = 0.0f;
for (int i = iBegin; i < iEnd; ++i)
{
if (i > 0)
{
sum += 1.0f / btScalar(i);
}
}
return sum;
}
};
virtual void stepSimulation( float deltaTime ) BT_OVERRIDE
{
if ( m_dynamicsWorld )
@@ -115,6 +130,14 @@ public:
// always step by 1/60 for benchmarking
m_dynamicsWorld->stepSimulation( 1.0f / 60.0f, 0 );
}
#if 0
{
// test parallelSum
TestSumBody testSumBody;
float testSum = btParallelSum( 1, 10000000, 10000, testSumBody );
printf( "sum = %f\n", testSum );
}
#endif
}
virtual void initPhysics() BT_OVERRIDE;

View File

@@ -21,7 +21,7 @@
void SampleThreadFunc(void* userPtr,void* lsMemory);
void* SamplelsMemoryFunc();
void SamplelsMemoryReleaseFunc(void* ptr);
#include <stdio.h>
//#include "BulletMultiThreaded/PlatformDefinitions.h"
@@ -34,6 +34,7 @@ b3ThreadSupportInterface* createThreadSupport(int numThreads)
b3PosixThreadSupport::ThreadConstructionInfo constructionInfo("testThreads",
SampleThreadFunc,
SamplelsMemoryFunc,
SamplelsMemoryReleaseFunc,
numThreads);
b3ThreadSupportInterface* threadSupport = new b3PosixThreadSupport(constructionInfo);
@@ -47,7 +48,7 @@ b3ThreadSupportInterface* createThreadSupport(int numThreads)
b3ThreadSupportInterface* createThreadSupport(int numThreads)
{
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads",SampleThreadFunc,SamplelsMemoryFunc,numThreads);
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads",SampleThreadFunc,SamplelsMemoryFunc,SamplelsMemoryReleaseFunc,numThreads);
b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport(threadConstructionInfo);
return threadSupport;
@@ -155,7 +156,11 @@ void* SamplelsMemoryFunc()
return new SampleThreadLocalStorage;
}
void SamplelsMemoryReleaseFunc(void* ptr)
{
SampleThreadLocalStorage* p = (SampleThreadLocalStorage*) ptr;
delete p;
}

View File

@@ -251,7 +251,8 @@ void b3PosixThreadSupport::startThreads(ThreadConstructionInfo& threadConstructi
spuStatus.m_mainSemaphore = m_mainSemaphore;
spuStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc();
spuStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc;
spuStatus.threadUsed = 0;
spuStatus.m_lsMemoryReleaseFunc = threadConstructionInfo.m_lsMemoryReleaseFunc;
spuStatus.threadUsed = 0;
printf("started thread %d \n",i);
@@ -277,8 +278,13 @@ void b3PosixThreadSupport::stopThreads()
destroySem(spuStatus.startSemaphore);
printf("semaphore destroyed\n");
checkPThreadFunction(pthread_join(spuStatus.thread,0));
if (spuStatus.m_lsMemoryReleaseFunc)
{
spuStatus.m_lsMemoryReleaseFunc( spuStatus.m_lsMemory);
}
}
printf("destroy main semaphore\n");
destroySem(m_mainSemaphore);
printf("main semaphore destroyed\n");

View File

@@ -35,6 +35,7 @@ subject to the following restrictions:
typedef void (*b3PosixThreadFunc)(void* userPtr,void* lsMemory);
typedef void* (*b3PosixlsMemorySetupFunc)();
typedef void (*b3PosixlsMemoryReleaseFunc)(void* ptr);
// b3PosixThreadSupport helps to initialize/shutdown libspe2, start/stop SPU tasks and communication
class b3PosixThreadSupport : public b3ThreadSupportInterface
@@ -55,6 +56,8 @@ public:
b3PosixThreadFunc m_userThreadFunc;
void* m_userPtr; //for taskDesc etc
b3PosixlsMemoryReleaseFunc m_lsMemoryReleaseFunc;
void* m_lsMemory; //initialized using PosixLocalStoreMemorySetupFunc
pthread_t thread;
@@ -83,12 +86,14 @@ public:
ThreadConstructionInfo(const char* uniqueName,
b3PosixThreadFunc userThreadFunc,
b3PosixlsMemorySetupFunc lsMemoryFunc,
b3PosixlsMemoryReleaseFunc lsMemoryReleaseFunc,
int numThreads=1,
int threadStackSize=65535
)
:m_uniqueName(uniqueName),
m_userThreadFunc(userThreadFunc),
m_lsMemoryFunc(lsMemoryFunc),
m_lsMemoryReleaseFunc(lsMemoryReleaseFunc),
m_numThreads(numThreads),
m_threadStackSize(threadStackSize)
{
@@ -98,6 +103,8 @@ public:
const char* m_uniqueName;
b3PosixThreadFunc m_userThreadFunc;
b3PosixlsMemorySetupFunc m_lsMemoryFunc;
b3PosixlsMemoryReleaseFunc m_lsMemoryReleaseFunc;
int m_numThreads;
int m_threadStackSize;

View File

@@ -289,6 +289,7 @@ void b3Win32ThreadSupport::startThreads(const Win32ThreadConstructionInfo& threa
threadStatus.m_threadHandle = handle;
threadStatus.m_lsMemory = threadConstructionInfo.m_lsMemoryFunc();
threadStatus.m_userThreadFunc = threadConstructionInfo.m_userThreadFunc;
threadStatus.m_lsMemoryReleaseFunc = threadConstructionInfo.m_lsMemoryReleaseFunc;
printf("started %s thread %d with threadHandle %p\n",threadConstructionInfo.m_uniqueName,i,handle);
@@ -312,9 +313,12 @@ void b3Win32ThreadSupport::stopThreads()
{
WaitForSingleObject(threadStatus.m_eventCompletetHandle, INFINITE);
}
delete threadStatus.m_lsMemory;
if (threadStatus.m_lsMemoryReleaseFunc)
{
threadStatus.m_lsMemoryReleaseFunc(threadStatus.m_lsMemory);
}
threadStatus.m_userPtr = 0;
SetEvent(threadStatus.m_eventStartHandle);
WaitForSingleObject(threadStatus.m_eventCompletetHandle, INFINITE);

View File

@@ -26,6 +26,7 @@ subject to the following restrictions:
typedef void (*b3Win32ThreadFunc)(void* userPtr,void* lsMemory);
typedef void* (*b3Win32lsMemorySetupFunc)();
typedef void (*b3Win32lsMemoryReleaseFunc)(void*);
///b3Win32ThreadSupport helps to initialize/shutdown libspe2, start/stop SPU tasks and communication
@@ -43,6 +44,8 @@ public:
void* m_userPtr; //for taskDesc etc
void* m_lsMemory; //initialized using Win32LocalStoreMemorySetupFunc
b3Win32lsMemoryReleaseFunc m_lsMemoryReleaseFunc;
void* m_threadHandle; //this one is calling 'Win32ThreadFunc'
void* m_eventStartHandle;
@@ -67,12 +70,14 @@ public:
Win32ThreadConstructionInfo(const char* uniqueName,
b3Win32ThreadFunc userThreadFunc,
b3Win32lsMemorySetupFunc lsMemoryFunc,
b3Win32lsMemoryReleaseFunc lsMemoryReleaseFunc,
int numThreads=1,
int threadStackSize=65535
)
:m_uniqueName(uniqueName),
m_userThreadFunc(userThreadFunc),
m_lsMemoryFunc(lsMemoryFunc),
m_lsMemoryReleaseFunc(lsMemoryReleaseFunc),
m_numThreads(numThreads),
m_threadStackSize(threadStackSize),
m_priority(0)
@@ -83,6 +88,7 @@ public:
const char* m_uniqueName;
b3Win32ThreadFunc m_userThreadFunc;
b3Win32lsMemorySetupFunc m_lsMemoryFunc;
b3Win32lsMemoryReleaseFunc m_lsMemoryReleaseFunc;
int m_numThreads;
int m_threadStackSize;
int m_priority;

View File

@@ -1,448 +0,0 @@
#include "LinearMath/btTransform.h"
#include "../Utils/b3Clock.h"
#include "LinearMath/btAlignedObjectArray.h"
#include "LinearMath/btThreads.h"
#include "LinearMath/btQuickprof.h"
#include <stdio.h>
#include <algorithm>
typedef void( *btThreadFunc )( void* userPtr, void* lsMemory );
typedef void* ( *btThreadLocalStorageFunc )();
#if BT_THREADSAFE
#if defined( _WIN32 )
#include "b3Win32ThreadSupport.h"
b3ThreadSupportInterface* createThreadSupport( int numThreads, btThreadFunc threadFunc, btThreadLocalStorageFunc localStoreFunc, const char* uniqueName )
{
b3Win32ThreadSupport::Win32ThreadConstructionInfo constructionInfo( uniqueName, threadFunc, localStoreFunc, numThreads );
//constructionInfo.m_priority = 0; // highest priority (the default) -- can cause erratic performance when numThreads > numCores
// we don't want worker threads to be higher priority than the main thread or the main thread could get
// totally shut out and unable to tell the workers to stop
constructionInfo.m_priority = -1; // normal priority
b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport( constructionInfo );
return threadSupport;
}
#else // #if defined( _WIN32 )
#include "b3PosixThreadSupport.h"
b3ThreadSupportInterface* createThreadSupport( int numThreads, btThreadFunc threadFunc, btThreadLocalStorageFunc localStoreFunc, const char* uniqueName)
{
b3PosixThreadSupport::ThreadConstructionInfo constructionInfo( uniqueName, threadFunc, localStoreFunc, numThreads );
b3ThreadSupportInterface* threadSupport = new b3PosixThreadSupport( constructionInfo );
return threadSupport;
}
#endif // #else // #if defined( _WIN32 )
///
/// getNumHardwareThreads()
///
///
/// https://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine
///
#if __cplusplus >= 201103L
#include <thread>
int getNumHardwareThreads()
{
return std::thread::hardware_concurrency();
}
#elif defined( _WIN32 )
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
int getNumHardwareThreads()
{
// caps out at 32
SYSTEM_INFO info;
GetSystemInfo( &info );
return info.dwNumberOfProcessors;
}
#else
int getNumHardwareThreads()
{
return 0; // don't know
}
#endif
struct WorkerThreadStatus
{
enum Type
{
kInvalid,
kWaitingForWork,
kWorking,
kSleeping,
};
};
struct IJob
{
virtual void executeJob() = 0;
};
class ParallelForJob : public IJob
{
const btIParallelForBody* mBody;
int mBegin;
int mEnd;
public:
ParallelForJob()
{
mBody = NULL;
mBegin = 0;
mEnd = 0;
}
void init( int iBegin, int iEnd, const btIParallelForBody& body )
{
mBody = &body;
mBegin = iBegin;
mEnd = iEnd;
}
virtual void executeJob() BT_OVERRIDE
{
BT_PROFILE( "executeJob" );
// call the functor body to do the work
mBody->forLoop( mBegin, mEnd );
}
};
struct JobContext
{
JobContext()
{
m_queueLock = NULL;
m_headIndex = 0;
m_tailIndex = 0;
m_workersShouldCheckQueue = false;
m_useSpinMutex = false;
}
b3CriticalSection* m_queueLock;
btSpinMutex m_mutex;
volatile bool m_workersShouldCheckQueue;
btAlignedObjectArray<IJob*> m_jobQueue;
bool m_queueIsEmpty;
int m_tailIndex;
int m_headIndex;
bool m_useSpinMutex;
void lockQueue()
{
if ( m_useSpinMutex )
{
m_mutex.lock();
}
else
{
m_queueLock->lock();
}
}
void unlockQueue()
{
if ( m_useSpinMutex )
{
m_mutex.unlock();
}
else
{
m_queueLock->unlock();
}
}
void clearQueue()
{
lockQueue();
m_headIndex = 0;
m_tailIndex = 0;
m_queueIsEmpty = true;
unlockQueue();
m_jobQueue.resizeNoInitialize( 0 );
}
void submitJob( IJob* job )
{
m_jobQueue.push_back( job );
lockQueue();
m_tailIndex++;
m_queueIsEmpty = false;
unlockQueue();
}
IJob* consumeJob()
{
if ( m_queueIsEmpty )
{
// lock free path. even if this is taken erroneously it isn't harmful
return NULL;
}
IJob* job = NULL;
lockQueue();
if ( !m_queueIsEmpty )
{
job = m_jobQueue[ m_headIndex++ ];
if ( m_headIndex == m_tailIndex )
{
m_queueIsEmpty = true;
}
}
unlockQueue();
return job;
}
};
struct WorkerThreadLocalStorage
{
int threadId;
WorkerThreadStatus::Type status;
};
static void WorkerThreadFunc( void* userPtr, void* lsMemory )
{
BT_PROFILE( "WorkerThreadFunc" );
WorkerThreadLocalStorage* localStorage = (WorkerThreadLocalStorage*) lsMemory;
localStorage->status = WorkerThreadStatus::kWaitingForWork;
//printf( "WorkerThreadFunc: worker %d start working\n", localStorage->threadId );
JobContext* jobContext = (JobContext*) userPtr;
while ( jobContext->m_workersShouldCheckQueue )
{
if ( IJob* job = jobContext->consumeJob() )
{
localStorage->status = WorkerThreadStatus::kWorking;
job->executeJob();
localStorage->status = WorkerThreadStatus::kWaitingForWork;
}
else
{
// todo: spin wait a bit to avoid hammering the empty queue
}
}
//printf( "WorkerThreadFunc stop working\n" );
localStorage->status = WorkerThreadStatus::kSleeping;
// go idle
}
static void* WorkerThreadAllocFunc()
{
return new WorkerThreadLocalStorage;
}
class btTaskSchedulerDefault : public btITaskScheduler
{
JobContext m_jobContext;
b3ThreadSupportInterface* m_threadSupport;
btAlignedObjectArray<ParallelForJob> m_jobs;
btSpinMutex m_antiNestingLock; // prevent nested parallel-for
int m_numThreads;
int m_numWorkerThreads;
int m_numWorkersRunning;
public:
btTaskSchedulerDefault() : btITaskScheduler("ThreadSupport")
{
m_threadSupport = NULL;
m_numThreads = getNumHardwareThreads();
// if can't detect number of cores,
if ( m_numThreads == 0 )
{
// take a guess
m_numThreads = 4;
}
m_numWorkerThreads = m_numThreads - 1;
m_numWorkersRunning = 0;
}
virtual ~btTaskSchedulerDefault()
{
shutdown();
}
void init()
{
int maxNumWorkerThreads = BT_MAX_THREAD_COUNT - 1;
m_threadSupport = createThreadSupport( maxNumWorkerThreads, WorkerThreadFunc, WorkerThreadAllocFunc, "TaskScheduler" );
m_jobContext.m_queueLock = m_threadSupport->createCriticalSection();
for ( int i = 0; i < maxNumWorkerThreads; i++ )
{
WorkerThreadLocalStorage* storage = (WorkerThreadLocalStorage*) m_threadSupport->getThreadLocalMemory( i );
btAssert( storage );
storage->threadId = i;
storage->status = WorkerThreadStatus::kSleeping;
}
setWorkersActive( false ); // no work for them yet
}
virtual void shutdown()
{
setWorkersActive( false );
waitForWorkersToSleep();
m_threadSupport->deleteCriticalSection( m_jobContext.m_queueLock );
m_jobContext.m_queueLock = NULL;
delete m_threadSupport;
m_threadSupport = NULL;
}
void setWorkersActive( bool active )
{
m_jobContext.m_workersShouldCheckQueue = active;
}
virtual int getMaxNumThreads() const BT_OVERRIDE
{
return BT_MAX_THREAD_COUNT;
}
virtual int getNumThreads() const BT_OVERRIDE
{
return m_numThreads;
}
virtual void setNumThreads( int numThreads ) BT_OVERRIDE
{
m_numThreads = btMax( btMin(numThreads, int(BT_MAX_THREAD_COUNT)), 1 );
m_numWorkerThreads = m_numThreads - 1;
}
void waitJobs()
{
BT_PROFILE( "waitJobs" );
// have the main thread work until the job queue is empty
for ( ;; )
{
if ( IJob* job = m_jobContext.consumeJob() )
{
job->executeJob();
}
else
{
break;
}
}
// done with jobs for now, tell workers to rest
setWorkersActive( false );
waitForWorkersToSleep();
}
void wakeWorkers()
{
BT_PROFILE( "wakeWorkers" );
btAssert( m_jobContext.m_workersShouldCheckQueue );
// tell each worker thread to start working
for ( int i = 0; i < m_numWorkerThreads; i++ )
{
m_threadSupport->runTask( B3_THREAD_SCHEDULE_TASK, &m_jobContext, i );
m_numWorkersRunning++;
}
}
void waitForWorkersToSleep()
{
BT_PROFILE( "waitForWorkersToSleep" );
while ( m_numWorkersRunning > 0 )
{
int iThread;
int threadStatus;
m_threadSupport->waitForResponse( &iThread, &threadStatus ); // wait for worker threads to finish working
m_numWorkersRunning--;
}
//m_threadSupport->waitForAllTasksToComplete();
for ( int i = 0; i < m_numWorkerThreads; i++ )
{
//m_threadSupport->waitForTaskCompleted( i );
WorkerThreadLocalStorage* storage = (WorkerThreadLocalStorage*) m_threadSupport->getThreadLocalMemory( i );
btAssert( storage );
btAssert( storage->status == WorkerThreadStatus::kSleeping );
}
}
virtual void parallelFor( int iBegin, int iEnd, int grainSize, const btIParallelForBody& body ) BT_OVERRIDE
{
BT_PROFILE( "parallelFor_ThreadSupport" );
btAssert( iEnd >= iBegin );
btAssert( grainSize >= 1 );
int iterationCount = iEnd - iBegin;
if ( iterationCount > grainSize && m_numWorkerThreads > 0 && m_antiNestingLock.tryLock() )
{
int jobCount = ( iterationCount + grainSize - 1 ) / grainSize;
btAssert( jobCount >= 2 ); // need more than one job for multithreading
if ( jobCount > m_jobs.size() )
{
m_jobs.resize( jobCount );
}
if ( jobCount > m_jobContext.m_jobQueue.capacity() )
{
m_jobContext.m_jobQueue.reserve( jobCount );
}
m_jobContext.clearQueue();
// prepare worker threads for incoming work
setWorkersActive( true );
wakeWorkers();
// submit all of the jobs
int iJob = 0;
for ( int i = iBegin; i < iEnd; i += grainSize )
{
btAssert( iJob < jobCount );
int iE = btMin( i + grainSize, iEnd );
ParallelForJob& job = m_jobs[ iJob ];
job.init( i, iE, body );
m_jobContext.submitJob( &job );
iJob++;
}
// put the main thread to work on emptying the job queue and then wait for all workers to finish
waitJobs();
m_antiNestingLock.unlock();
}
else
{
BT_PROFILE( "parallelFor_mainThread" );
// just run on main thread
body.forLoop( iBegin, iEnd );
}
}
};
btITaskScheduler* createDefaultTaskScheduler()
{
btTaskSchedulerDefault* ts = new btTaskSchedulerDefault();
ts->init();
return ts;
}
#else // #if BT_THREADSAFE
btITaskScheduler* createDefaultTaskScheduler()
{
return NULL;
}
#endif // #else // #if BT_THREADSAFE

View File

@@ -1,26 +0,0 @@
/*
Copyright (c) 2003-2014 Erwin Coumans http://bullet.googlecode.com
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BT_TASK_SCHEDULER_H
#define BT_TASK_SCHEDULER_H
class btITaskScheduler;
btITaskScheduler* createDefaultTaskScheduler();
#endif // BT_TASK_SCHEDULER_H

View File

@@ -38,7 +38,7 @@
#include "OpenGLInclude.h"
#include "third_party/GL/EGL/egl.h"
#include "third_party/GL/gl/include/EGL/egl.h"
#include "third_party/GL/gl/include/EGL/eglext.h"
#include "third_party/GL/gl/include/GL/gl.h"

View File

@@ -361,7 +361,8 @@ GLInstancingRenderer::GLInstancingRenderer(int maxNumObjectCapacity, int maxShap
m_textureinitialized(false),
m_screenWidth(0),
m_screenHeight(0),
m_upAxis(1)
m_upAxis(1),
m_planeReflectionShapeIndex(-1)
{
m_data = new InternalDataRenderer;
@@ -508,6 +509,16 @@ void GLInstancingRenderer::writeSingleInstanceColorToCPU(const double* color, in
b3Assert(pg);
int srcIndex = pg->m_internalInstanceIndex;
int shapeIndex = pg->m_shapeIndex;
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
if (color[3]<1)
{
gfxObj->m_flags |= eGfxTransparency;
} else
{
gfxObj->m_flags &= ~eGfxTransparency;
}
m_data->m_instance_colors_ptr[srcIndex*4+0]=float(color[0]);
m_data->m_instance_colors_ptr[srcIndex*4+1]=float(color[1]);
m_data->m_instance_colors_ptr[srcIndex*4+2]=float(color[2]);
@@ -519,6 +530,16 @@ void GLInstancingRenderer::writeSingleInstanceColorToCPU(const float* color, int
b3PublicGraphicsInstance* pg = m_data->m_publicGraphicsInstances.getHandle(srcIndex2);
b3Assert(pg);
int srcIndex = pg->m_internalInstanceIndex;
int shapeIndex = pg->m_shapeIndex;
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
if (color[3]<1)
{
gfxObj->m_flags |= eGfxTransparency;
} else
{
gfxObj->m_flags &= ~eGfxTransparency;
}
m_data->m_instance_colors_ptr[srcIndex*4+0]=color[0];
m_data->m_instance_colors_ptr[srcIndex*4+1]=color[1];
@@ -1597,13 +1618,44 @@ void GLInstancingRenderer::renderScene()
{
renderSceneInternal(B3_CREATE_SHADOWMAP_RENDERMODE);
//glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
//renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE_REFLECTION);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
if (m_planeReflectionShapeIndex>=0)
{
/* Don't update color or depth. */
glDisable(GL_DEPTH_TEST);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
/* Draw 1 into the stencil buffer. */
glEnable(GL_STENCIL_TEST);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
/* Now render floor; floor pixels just get their stencil set to 1. */
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE_REFLECTION_PLANE);
/* Re-enable update of color and depth. */
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glEnable(GL_DEPTH_TEST);
/* Now, only render where stencil is set to 1. */
glStencilFunc(GL_EQUAL, 1, 0xffffffff); /* draw if ==1 */
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
//draw the reflection objects
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE_REFLECTION);
glDisable(GL_STENCIL_TEST);
}
renderSceneInternal(B3_USE_SHADOWMAP_RENDERMODE);
}
else if (m_data->m_useProjectiveTexture)
{
renderSceneInternal(B3_USE_PROJECTIVE_TEXTURE_RENDERMODE);
}
else
@@ -2040,6 +2092,13 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
{
int renderMode=orgRenderMode;
bool reflectionPass = false;
bool reflectionPlanePass = false;
if (orgRenderMode==B3_USE_SHADOWMAP_RENDERMODE_REFLECTION_PLANE)
{
reflectionPlanePass = true;
renderMode = B3_USE_SHADOWMAP_RENDERMODE;
}
if (orgRenderMode==B3_USE_SHADOWMAP_RENDERMODE_REFLECTION)
{
reflectionPass = true;
@@ -2085,8 +2144,8 @@ void GLInstancingRenderer::renderSceneInternal(int orgRenderMode)
//GLfloat depthModelViewMatrix2[4][4];
// For projective texture mapping
float textureProjectionMatrix[4][4];
GLfloat textureModelViewMatrix[4][4];
//float textureProjectionMatrix[4][4];
//GLfloat textureModelViewMatrix[4][4];
// Compute the MVP matrix from the light's point of view
if (renderMode==B3_CREATE_SHADOWMAP_RENDERMODE)
@@ -2254,6 +2313,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
for (int obj=0;obj<m_graphicsInstances.size();obj++)
{
b3GraphicsInstance* gfxObj = m_graphicsInstances[obj];
if (gfxObj->m_numGraphicsInstances)
{
SortableTransparentInstance inst;
@@ -2300,9 +2360,16 @@ b3Assert(glGetError() ==GL_NO_ERROR);
{
for (int i=0;i<transparentInstances.size();i++)
{
int shapeIndex = transparentInstances[i].m_shapeIndex;
//during a reflectionPlanePass, only draw the plane, nothing else
if (reflectionPlanePass)
{
if (shapeIndex!=m_planeReflectionShapeIndex)
continue;
}
b3GraphicsInstance* gfxObj = m_graphicsInstances[shapeIndex];
//only draw stuff (opaque/transparent) if it is the right pass
@@ -2340,7 +2407,7 @@ b3Assert(glGetError() ==GL_NO_ERROR);
curBindTexture = m_data->m_defaultTexturehandle;
}
//disable lazy evaluation, it just leads to bugs
//disable lazy evaluation, it just leads to bugs
//if (lastBindTexture != curBindTexture)
{
glBindTexture(GL_TEXTURE_2D,curBindTexture);
@@ -2503,6 +2570,8 @@ b3Assert(glGetError() ==GL_NO_ERROR);
float MVP[16];
if (reflectionPass)
{
//todo: create an API to select this reflection matrix, to allow
//reflection planes different from Z-axis up through (0,0,0)
float tmp[16];
float reflectionMatrix[16] = {1,0,0,0,
0,1,0,0,
@@ -2669,6 +2738,11 @@ void GLInstancingRenderer::CleanupShaders()
{
}
void GLInstancingRenderer::setPlaneReflectionShapeIndex(int index)
{
m_planeReflectionShapeIndex = index;
}
void GLInstancingRenderer::enableShadowMap()
{
glActiveTexture(GL_TEXTURE0);

View File

@@ -39,6 +39,8 @@ class GLInstancingRenderer : public CommonRenderInterface
int m_screenHeight;
int m_upAxis;
int m_planeReflectionShapeIndex;
int registerGraphicsInstanceInternal(int shapeIndex, const float* position, const float* quaternion, const float* color, const float* scaling);
@@ -151,6 +153,8 @@ public:
virtual int getTotalNumInstances() const;
virtual void enableShadowMap();
virtual void setPlaneReflectionShapeIndex(int index);
virtual void clearZBuffer();

View File

@@ -17,12 +17,20 @@ subject to the following restrictions:
#ifndef __OPENGL_INCLUDE_H
#define __OPENGL_INCLUDE_H
#ifdef BT_NO_GLAD
#include "third_party/GL/gl/include/EGL/egl.h"
#include "third_party/GL/gl/include/EGL/eglext.h"
#include "third_party/GL/gl/include/GL/gl.h"
#else
#ifdef B3_USE_GLFW
#include "glad/glad.h"
#include <GLFW/glfw3.h>
#else
#include "glad/glad.h"
#endif //B3_USE_GLFW
#endif //BT_NO_GLAD
//disable glGetError
//#undef glGetError
//#define glGetError MyGetError

View File

@@ -17,12 +17,17 @@ subject to the following restrictions:
#ifndef __OPENGL_INCLUDE_H
#define __OPENGL_INCLUDE_H
#ifdef BT_NO_GLAD
#include "third_party/GL/gl/include/EGL/egl.h"
#include "third_party/GL/gl/include/EGL/eglext.h"
#include "third_party/GL/gl/include/GL/gl.h"
#else
#ifdef B3_USE_GLFW
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#else
#include "glad/glad.h"
#endif //B3_USE_GLFW
#endif //BT_NO_GLAD
#endif //__OPENGL_INCLUDE_H

View File

@@ -295,7 +295,7 @@ static void printGLString(const char *name, GLenum s) {
bool sOpenGLVerbose = true;
SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, bool allowRetina)
SimpleOpenGL3App::SimpleOpenGL3App(const char* title, int width, int height, bool allowRetina, int maxNumObjectCapacity, int maxShapeCapacityInBytes)
{
gApp = this;
@@ -369,7 +369,7 @@ SimpleOpenGL3App::SimpleOpenGL3App( const char* title, int width,int height, boo
b3Assert(glGetError() ==GL_NO_ERROR);
m_instancingRenderer = new GLInstancingRenderer(128*1024,128*1024*1024);
m_instancingRenderer = new GLInstancingRenderer(maxNumObjectCapacity, maxShapeCapacityInBytes);
m_primRenderer = new GLPrimitiveRenderer(width,height);

View File

@@ -16,7 +16,8 @@ struct SimpleOpenGL3App : public CommonGraphicsApp
class GLInstancingRenderer* m_instancingRenderer;
virtual void setBackgroundColor(float red, float green, float blue);
SimpleOpenGL3App(const char* title, int width,int height, bool allowRetina=true);
SimpleOpenGL3App(const char* title, int width,int height, bool allowRetina=true, int maxNumObjectCapacity = 128 * 1024, int maxShapeCapacityInBytes = 128 * 1024 * 1024);
virtual ~SimpleOpenGL3App();
virtual int registerCubeShape(float halfExtentsX=1.f,float halfExtentsY=1.f, float halfExtentsZ = 1.f, int textureIndex = -1, float textureScaling = 1);

View File

@@ -6,11 +6,6 @@
#include<stdio.h>
#include<stdlib.h>
#ifdef GLEW_STATIC
#include "glad/glad.h"
#else
#include <GL/glew.h>
#endif//GLEW_STATIC
#ifdef GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS
#include "glad/glad_glx.h"

View File

@@ -43,10 +43,7 @@ myfiles =
"../../examples/Utils/b3ResourcePath.h",
"../../examples/Utils/RobotLoggingUtil.cpp",
"../../examples/Utils/RobotLoggingUtil.h",
"../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp",
"../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
"../../examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",

View File

@@ -77,10 +77,7 @@ SharedMemoryCommands.h
../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp
../Importers/ImportColladaDemo/ColladaGraphicsInstance.h
../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../ThirdPartyLibs/tinyxml/tinystr.cpp
../ThirdPartyLibs/tinyxml/tinyxml.cpp
../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
../ThirdPartyLibs/tinyxml2/tinyxml2.cpp
../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp
../ThirdPartyLibs/stb_image/stb_image.cpp
../MultiThreading/b3ThreadSupportInterface.cpp
@@ -214,7 +211,7 @@ IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
#VR/OpenVR only on Windows and Mac OSX for now
#VR/OpenVR on Windows and Mac OSX
IF (WIN32 OR APPLE)
INCLUDE_DIRECTORIES(
@@ -328,4 +325,80 @@ IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(App_PhysicsServer_SharedMemory_VR PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
#VR/OpenVR on Linux
ELSE(WIN32 OR APPLE)
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
LINK_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/bin/linux64)
ELSE()
LINK_DIRECTORIES(${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/bin/linux32)
ENDIF()
ADD_EXECUTABLE(App_PhysicsServer_SharedMemory_VR
${SharedMemory_SRCS}
../StandaloneMain/hellovr_opengl_main.cpp
../ExampleBrowser/OpenGLGuiHelper.cpp
../ExampleBrowser/GL_ShapeDrawer.cpp
../ExampleBrowser/CollisionShape2TriangleMesh.cpp
../RenderingExamples/TinyVRGui.cpp
../RenderingExamples/TinyVRGui.h
../RenderingExamples/TimeSeriesCanvas.cpp
../RenderingExamples/TimeSeriesFontData.cpp
../MultiThreading/b3PosixThreadSupport.cpp
../MultiThreading/b3PosixThreadSupport.h
../ThirdPartyLibs/openvr/samples/shared/lodepng.cpp
../ThirdPartyLibs/openvr/samples/shared/lodepng.h
../ThirdPartyLibs/openvr/samples/shared/Matrices.cpp
../ThirdPartyLibs/openvr/samples/shared/Matrices.h
../ThirdPartyLibs/openvr/samples/shared/pathtools.cpp
../ThirdPartyLibs/openvr/samples/shared/pathtools.h
../ThirdPartyLibs/openvr/samples/shared/strtools.cpp
../ThirdPartyLibs/openvr/samples/shared/strtools.h
../ThirdPartyLibs/openvr/samples/shared/Vectors.h
)
target_include_directories(App_PhysicsServer_SharedMemory_VR PRIVATE
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/Glew
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/headers
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/samples
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/openvr/samples/shared
)
target_compile_definitions(App_PhysicsServer_SharedMemory_VR PRIVATE
POSIX
LINUX
BT_ENABLE_VR
GLEW_STATIC
GLEW_INIT_OPENGL11_FUNCTIONS=1
GLEW_DYNAMIC_LOAD_ALL_GLX_FUNCTIONS=1
)
target_compile_options(App_PhysicsServer_SharedMemory_VR PRIVATE
-std=c++11
)
target_link_libraries(App_PhysicsServer_SharedMemory_VR PRIVATE
openvr_api
pthread
${DL}
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
Bullet3Common
BulletWorldImporter
BulletInverseDynamicsUtils
BulletInverseDynamics
BulletDynamics
BulletCollision
LinearMath
BussIK
OpenGLWindow
)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(App_PhysicsServer_SharedMemory_VR PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(App_PhysicsServer_SharedMemory_VR PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(App_PhysicsServer_SharedMemory_VR PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
ENDIF(WIN32 OR APPLE)

View File

@@ -11,6 +11,8 @@
#include "../MultiThreading/b3ThreadSupportInterface.h"
void UDPThreadFunc(void* userPtr, void* lsMemory);
void* UDPlsMemoryFunc();
void UDPlsMemoryReleaseFunc(void* ptr);
bool gVerboseNetworkMessagesClient = false;
#ifndef _WIN32
@@ -21,6 +23,7 @@ b3ThreadSupportInterface* createUDPThreadSupport(int numThreads)
b3PosixThreadSupport::ThreadConstructionInfo constructionInfo("UDPThread",
UDPThreadFunc,
UDPlsMemoryFunc,
UDPlsMemoryReleaseFunc,
numThreads);
b3ThreadSupportInterface* threadSupport = new b3PosixThreadSupport(constructionInfo);
@@ -34,7 +37,7 @@ b3ThreadSupportInterface* createUDPThreadSupport(int numThreads)
b3ThreadSupportInterface* createUDPThreadSupport(int numThreads)
{
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("UDPThread", UDPThreadFunc, UDPlsMemoryFunc, numThreads);
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("UDPThread", UDPThreadFunc, UDPlsMemoryFunc,UDPlsMemoryReleaseFunc, numThreads);
b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport(threadConstructionInfo);
return threadSupport;
@@ -436,6 +439,11 @@ void* UDPlsMemoryFunc()
return new UDPThreadLocalStorage;
}
void UDPlsMemoryReleaseFunc(void* ptr)
{
UDPThreadLocalStorage* p = (UDPThreadLocalStorage*) ptr;
delete p;
}

View File

@@ -150,16 +150,16 @@ struct InternalVisualShapeData
int m_tinyRendererVisualShapeIndex;
int m_OpenGLGraphicsIndex;
UrdfVisual m_visualShape;
btTransform m_localInertiaFrame;
std::string m_pathPrefix;
b3AlignedObjectArray<UrdfVisual> m_visualShapes;
b3AlignedObjectArray<std::string> m_pathPrefixes;
void clear()
{
m_tinyRendererVisualShapeIndex = 0;
m_OpenGLGraphicsIndex = 0;
m_localInertiaFrame.setIdentity();
m_pathPrefix = "";
m_tinyRendererVisualShapeIndex = -1;
m_OpenGLGraphicsIndex = -1;
m_visualShapes.clear();
m_pathPrefixes.clear();
}
};
@@ -482,10 +482,10 @@ struct CommandLogPlayback
SharedMemoryCommand unused;
#endif//BACKWARD_COMPAT
bool result = false;
size_t s = 0;
if (m_file)
{
size_t s = 0;
int commandType = -1;
if (m_fileIs64bit)
@@ -518,8 +518,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_mjcfArguments = unused.m_mjcfArguments;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_mjcfArguments,sizeof(MjcfArgs),1,m_file);
s=fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_mjcfArguments,sizeof(MjcfArgs),1,m_file);
#endif
result=true;
break;
@@ -529,8 +529,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_sdfRequestInfoArgs = unused.m_sdfRequestInfoArgs;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_sdfRequestInfoArgs,sizeof(SdfRequestInfoArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_sdfRequestInfoArgs,sizeof(SdfRequestInfoArgs),1,m_file);
#endif
result=true;
break;
@@ -540,8 +540,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_requestVisualShapeDataArguments = unused.m_requestVisualShapeDataArguments;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_requestVisualShapeDataArguments,sizeof(RequestVisualShapeDataArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_requestVisualShapeDataArguments,sizeof(RequestVisualShapeDataArgs),1,m_file);
#endif
result=true;
break;
@@ -551,8 +551,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_urdfArguments = unused.m_urdfArguments;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_urdfArguments,sizeof(UrdfArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_urdfArguments,sizeof(UrdfArgs),1,m_file);
#endif
result=true;
break;
@@ -562,8 +562,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_initPoseArgs = unused.m_initPoseArgs;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_initPoseArgs,sizeof(InitPoseArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_initPoseArgs,sizeof(InitPoseArgs),1,m_file);
#endif
result=true;
@@ -574,8 +574,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_requestActualStateInformationCommandArgument = unused.m_requestActualStateInformationCommandArgument;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_requestActualStateInformationCommandArgument,sizeof(RequestActualStateArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_requestActualStateInformationCommandArgument,sizeof(RequestActualStateArgs),1,m_file);
#endif
result=true;
break;
@@ -585,8 +585,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_sendDesiredStateCommandArgument = unused.m_sendDesiredStateCommandArgument;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_sendDesiredStateCommandArgument ,sizeof(SendDesiredStateArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_sendDesiredStateCommandArgument ,sizeof(SendDesiredStateArgs),1,m_file);
#endif
result = true;
@@ -597,8 +597,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_physSimParamArgs = unused.m_physSimParamArgs;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_physSimParamArgs ,sizeof(b3PhysicsSimulationParameters),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_physSimParamArgs ,sizeof(b3PhysicsSimulationParameters),1,m_file);
#endif
result = true;
@@ -609,8 +609,8 @@ struct CommandLogPlayback
#ifdef BACKWARD_COMPAT
cmd->m_requestContactPointArguments = unused.m_requestContactPointArguments;
#else
fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
fread(&cmd->m_requestContactPointArguments ,sizeof(RequestContactDataArgs),1,m_file);
s = fread(&cmd->m_updateFlags,sizeof(int),1,m_file);
s = fread(&cmd->m_requestContactPointArguments ,sizeof(RequestContactDataArgs),1,m_file);
#endif
result = true;
@@ -1921,10 +1921,13 @@ struct ProgrammaticUrdfInterface : public URDFImporterInterface
const InternalVisualShapeHandle* visHandle = m_data->m_userVisualShapeHandles.getHandle(m_createBodyArgs.m_linkVisualShapeUniqueIds[linkIndex]);
if (visHandle)
{
if (visHandle->m_visualShape.m_geometry.m_hasLocalMaterial)
for (int i=0;i<visHandle->m_visualShapes.size();i++)
{
matCol = visHandle->m_visualShape.m_geometry.m_localMaterial.m_matColor;
return true;
if (visHandle->m_visualShapes[i].m_geometry.m_hasLocalMaterial)
{
matCol = visHandle->m_visualShapes[i].m_geometry.m_localMaterial.m_matColor;
return true;
}
}
}
}
@@ -2092,39 +2095,91 @@ struct ProgrammaticUrdfInterface : public URDFImporterInterface
b3Assert(0);
}
///quick hack: need to rethink the API/dependencies of this
virtual int convertLinkVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& inertialFrame) const
virtual int convertLinkVisualShapes(int linkIndex, const char* pathPrefix, const btTransform& localInertiaFrame) const
{
int graphicsIndex = -1;
double globalScaling = 1.f;//todo!
int flags=0;
BulletURDFImporter u2b(m_data->m_guiHelper, m_data->m_pluginManager.getRenderInterface(), globalScaling, flags);
u2b.setEnableTinyRenderer(m_data->m_enableTinyRenderer);
btAlignedObjectArray<GLInstanceVertex> vertices;
btAlignedObjectArray<int> indices;
btTransform startTrans; startTrans.setIdentity();
btAlignedObjectArray<BulletURDFTexture> textures;
if (m_createBodyArgs.m_linkVisualShapeUniqueIds[linkIndex]>=0)
{
const InternalVisualShapeHandle* visHandle = m_data->m_userVisualShapeHandles.getHandle(m_createBodyArgs.m_linkVisualShapeUniqueIds[linkIndex]);
InternalVisualShapeHandle* visHandle = m_data->m_userVisualShapeHandles.getHandle(m_createBodyArgs.m_linkVisualShapeUniqueIds[linkIndex]);
if (visHandle)
{
return visHandle->m_OpenGLGraphicsIndex;
if (visHandle->m_OpenGLGraphicsIndex>=0)
{
//instancing. assume the inertial frame is identical
graphicsIndex = visHandle->m_OpenGLGraphicsIndex;
} else
{
for (int v = 0;v<visHandle->m_visualShapes.size();v++)
{
u2b.convertURDFToVisualShapeInternal(&visHandle->m_visualShapes[v], pathPrefix, localInertiaFrame.inverse()*visHandle->m_visualShapes[v].m_linkLocalFrame, vertices, indices, textures);
}
if (vertices.size() && indices.size())
{
if (1)
{
int textureIndex = -1;
if (textures.size())
{
textureIndex = m_data->m_guiHelper->registerTexture(textures[0].textureData1, textures[0].m_width, textures[0].m_height);
}
{
B3_PROFILE("registerGraphicsShape");
graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, textureIndex);
visHandle->m_OpenGLGraphicsIndex = graphicsIndex;
}
}
}
}
}
}
return -1;
return graphicsIndex;
}
virtual void convertLinkVisualShapes2(int linkIndex, int urdfIndex, const char* pathPrefix, const btTransform& localInertiaFrame, class btCollisionObject* colObj, int bodyUniqueId) const
{
//if there is a visual, use it, otherwise convert collision shape back into UrdfCollision...
UrdfModel model;// = m_data->m_urdfParser.getModel();
UrdfLink link;
int colShapeUniqueId = m_createBodyArgs.m_linkCollisionShapeUniqueIds[urdfIndex];
if (colShapeUniqueId>=0)
if (m_createBodyArgs.m_linkVisualShapeUniqueIds[linkIndex]>=0)
{
InternalCollisionShapeHandle* handle = m_data->m_userCollisionShapeHandles.getHandle(colShapeUniqueId);
if (handle)
const InternalVisualShapeHandle* visHandle = m_data->m_userVisualShapeHandles.getHandle(m_createBodyArgs.m_linkVisualShapeUniqueIds[linkIndex]);
if (visHandle)
{
for (int i=0;i<handle->m_urdfCollisionObjects.size();i++)
for (int i=0;i<visHandle->m_visualShapes.size();i++)
{
link.m_collisionArray.push_back(handle->m_urdfCollisionObjects[i]);
link.m_visualArray.push_back(visHandle->m_visualShapes[i]);
}
}
}
if (link.m_visualArray.size()==0)
{
int colShapeUniqueId = m_createBodyArgs.m_linkCollisionShapeUniqueIds[urdfIndex];
if (colShapeUniqueId>=0)
{
InternalCollisionShapeHandle* handle = m_data->m_userCollisionShapeHandles.getHandle(colShapeUniqueId);
if (handle)
{
for (int i=0;i<handle->m_urdfCollisionObjects.size();i++)
{
link.m_collisionArray.push_back(handle->m_urdfCollisionObjects[i]);
}
}
}
}
@@ -3968,19 +4023,16 @@ bool PhysicsServerCommandProcessor::processCreateVisualShapeCommand(const struct
u2b.setEnableTinyRenderer(m_data->m_enableTinyRenderer);
btTransform localInertiaFrame;
localInertiaFrame.setIdentity();
btTransform childTrans;
childTrans.setIdentity();
const char* pathPrefix = "";
btAlignedObjectArray<GLInstanceVertex> vertices;
btAlignedObjectArray<int> indices;
btTransform startTrans; startTrans.setIdentity();
btAlignedObjectArray<BulletURDFTexture> textures;
int visualShapeUniqueId = -1;
UrdfVisual visualShape;
for (int userShapeIndex = 0; userShapeIndex< clientCmd.m_createUserShapeArgs.m_numUserShapes; userShapeIndex++)
{
btTransform childTrans;
childTrans.setIdentity();
visualShape.m_geometry.m_type = (UrdfGeomTypes)clientCmd.m_createUserShapeArgs.m_shapes[userShapeIndex].m_type;
char relativeFileName[1024];
char pathPrefix[1024];
@@ -4106,41 +4158,23 @@ bool PhysicsServerCommandProcessor::processCreateVisualShapeCommand(const struct
}
u2b.convertURDFToVisualShapeInternal(&visualShape, pathPrefix, localInertiaFrame.inverse()*childTrans, vertices, indices, textures);
}
if (vertices.size() && indices.size())
{
if (1)
if (visualShapeUniqueId<0)
{
int textureIndex = -1;
if (textures.size())
{
textureIndex = m_data->m_guiHelper->registerTexture(textures[0].textureData1, textures[0].m_width, textures[0].m_height);
}
int graphicsIndex = -1;
{
B3_PROFILE("registerGraphicsShape");
graphicsIndex = m_data->m_guiHelper->registerGraphicsShape(&vertices[0].xyzw[0], vertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, textureIndex);
if (graphicsIndex >= 0)
{
int visualShapeUniqueId = m_data->m_userVisualShapeHandles.allocHandle();
InternalVisualShapeHandle* visualHandle = m_data->m_userVisualShapeHandles.getHandle(visualShapeUniqueId);
visualHandle->m_OpenGLGraphicsIndex = graphicsIndex;
visualHandle->m_tinyRendererVisualShapeIndex = -1;
//tinyrenderer doesn't separate shape versus instance, so create it when creating the multibody instance
//store needed info for tinyrenderer
visualHandle->m_localInertiaFrame = localInertiaFrame;
visualHandle->m_visualShape = visualShape;
visualHandle->m_pathPrefix = pathPrefix[0] ? pathPrefix : "";
serverStatusOut.m_createUserShapeResultArgs.m_userShapeUniqueId = visualShapeUniqueId;
serverStatusOut.m_type = CMD_CREATE_VISUAL_SHAPE_COMPLETED;
}
}
visualShapeUniqueId = m_data->m_userVisualShapeHandles.allocHandle();
}
InternalVisualShapeHandle* visualHandle = m_data->m_userVisualShapeHandles.getHandle(visualShapeUniqueId);
visualHandle->m_OpenGLGraphicsIndex = -1;
visualHandle->m_tinyRendererVisualShapeIndex = -1;
//tinyrenderer doesn't separate shape versus instance, so create it when creating the multibody instance
//store needed info for tinyrenderer
visualShape.m_linkLocalFrame = childTrans;
visualHandle->m_visualShapes.push_back(visualShape);
visualHandle->m_pathPrefixes.push_back(pathPrefix[0] ? pathPrefix : "");
serverStatusOut.m_createUserShapeResultArgs.m_userShapeUniqueId = visualShapeUniqueId;
serverStatusOut.m_type = CMD_CREATE_VISUAL_SHAPE_COMPLETED;
}
return hasStatus;
@@ -4760,6 +4794,9 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
}
if (hasDesiredVelocity)
{
//disable velocity clamp in velocity mode
motor->setRhsClamp(SIMD_INFINITY);
btScalar maxImp = 1000000.f*m_data->m_physicsDeltaTime;
if ((clientCmd.m_sendDesiredStateCommandArgument.m_hasDesiredStateFlags[dofIndex]&SIM_DESIRED_STATE_HAS_MAX_FORCE)!=0)
{
@@ -4973,9 +5010,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
{
con->enableMotor(3+limitAxis,true);
con->setTargetVelocity(3+limitAxis, qdotTarget);
//this is max motor force impulse
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
con->setMaxMotorForce(3+limitAxis,torqueImpulse);
con->setMaxMotorForce(3+limitAxis, torque);
}
break;
}
@@ -4988,9 +5023,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
//next one is the maximum velocity to reach target position.
//the maximum velocity is limited by maxMotorForce
con->setTargetVelocity(3+limitAxis, 100);
//this is max motor force impulse
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
con->setMaxMotorForce(3+limitAxis,torqueImpulse);
con->setMaxMotorForce(3+limitAxis, torque);
con->enableMotor(3+limitAxis,true);
}
break;
@@ -5026,9 +5059,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
{
con->enableMotor(limitAxis,true);
con->setTargetVelocity(limitAxis, -qdotTarget);
//this is max motor force impulse
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
con->setMaxMotorForce(limitAxis,torqueImpulse);
con->setMaxMotorForce(limitAxis, torque);
break;
}
case CONTROL_MODE_POSITION_VELOCITY_PD:
@@ -5038,9 +5069,7 @@ bool PhysicsServerCommandProcessor::processSendDesiredStateCommand(const struct
//next one is the maximum velocity to reach target position.
//the maximum velocity is limited by maxMotorForce
con->setTargetVelocity(limitAxis, 100);
//this is max motor force impulse
btScalar torqueImpulse = torque*m_data->m_dynamicsWorld->getSolverInfo().m_timeStep;
con->setMaxMotorForce(limitAxis,torqueImpulse);
con->setMaxMotorForce(limitAxis, torque);
con->enableMotor(limitAxis,true);
break;
}
@@ -9665,6 +9694,12 @@ void PhysicsServerCommandProcessor::resetSimulation()
{
//clean up all data
#ifndef SKIP_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD
if (m_data && m_data->m_dynamicsWorld)
{
m_data->m_dynamicsWorld->getWorldInfo().m_sparsesdf.Reset();
}
#endif
if (m_data && m_data->m_guiHelper)
{
m_data->m_guiHelper->removeAllGraphicsInstances();

View File

@@ -92,6 +92,7 @@ static void saveCurrentSettingsVR(const btVector3& VRTeleportPos1)
bool gDebugRenderToggle = false;
void MotionThreadFunc(void* userPtr,void* lsMemory);
void* MotionlsMemoryFunc();
void MotionlsMemoryReleaseFunc(void* ptr);
#define MAX_MOTION_NUM_THREADS 1
enum
{
@@ -150,6 +151,7 @@ b3ThreadSupportInterface* createMotionThreadSupport(int numThreads)
b3PosixThreadSupport::ThreadConstructionInfo constructionInfo("MotionThreads",
MotionThreadFunc,
MotionlsMemoryFunc,
MotionlsMemoryReleaseFunc,
numThreads);
b3ThreadSupportInterface* threadSupport = new b3PosixThreadSupport(constructionInfo);
@@ -163,7 +165,7 @@ b3ThreadSupportInterface* createMotionThreadSupport(int numThreads)
b3ThreadSupportInterface* createMotionThreadSupport(int numThreads)
{
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("MotionThreads",MotionThreadFunc,MotionlsMemoryFunc,numThreads);
b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("MotionThreads",MotionThreadFunc,MotionlsMemoryFunc,MotionlsMemoryReleaseFunc,numThreads);
b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport(threadConstructionInfo);
return threadSupport;
@@ -486,6 +488,12 @@ void* MotionlsMemoryFunc()
return new MotionThreadLocalStorage;
}
void MotionlsMemoryReleaseFunc(void* ptr)
{
MotionThreadLocalStorage* p = (MotionThreadLocalStorage*) ptr;
delete p;
}
struct UserDebugDrawLine
@@ -756,6 +764,12 @@ public:
delete m_debugDraw;
m_debugDraw = 0;
}
for (int i=0;i<m_userDebugParams.size();i++)
{
delete m_userDebugParams[i];
}
m_userDebugParams.clear();
}
void setCriticalSection(b3CriticalSection* cs)

View File

@@ -170,7 +170,7 @@ bool PhysicsServerSharedMemory::connectSharedMemory( struct GUIHelperInterface*
}
} else
{
b3Error("Cannot connect to shared memory");
//b3Error("Cannot connect to shared memory");
m_data->m_areConnected[block] = false;
}
} while (counter++ < 10 && !m_data->m_areConnected[block]);

View File

@@ -23,7 +23,11 @@
typedef unsigned long long int smUint64_t;
#endif
#define SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE (8*1024*1024)
#ifdef __APPLE__
#define SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE (512*1024)
#else
#define SHARED_MEMORY_MAX_STREAM_CHUNK_SIZE (8*1024*1024)
#endif
#define SHARED_MEMORY_SERVER_TEST_C
#define MAX_DEGREE_OF_FREEDOM 128

View File

@@ -648,6 +648,7 @@ enum b3ConfigureDebugVisualizerEnum
COV_ENABLE_RGB_BUFFER_PREVIEW,
COV_ENABLE_DEPTH_BUFFER_PREVIEW,
COV_ENABLE_SEGMENTATION_MARK_PREVIEW,
COV_ENABLE_PLANAR_REFLECTION,
};

View File

@@ -593,7 +593,7 @@ void TinyRendererVisualShapeConverter::convertVisualShapes(
colorIndex &=3;
btVector4 color;
color = sColors[colorIndex];
float rgbaColor[4] = {color[0],color[1],color[2],color[3]};
float rgbaColor[4] = {(float)color[0],(float)color[1],(float)color[2],(float)color[3]};
//if (colObj->getCollisionShape()->getShapeType()==STATIC_PLANE_PROXYTYPE)
//{
// color.setValue(1,1,1,1);
@@ -773,7 +773,7 @@ void TinyRendererVisualShapeConverter::changeRGBAColor(int bodyUniqueId, int lin
TinyRendererObjectArray** ptrptr = m_data->m_swRenderInstances.getAtIndex(i);
if (ptrptr && *ptrptr)
{
float rgba[4] = {rgbaColor[0], rgbaColor[1], rgbaColor[2], rgbaColor[3]};
float rgba[4] = {(float)rgbaColor[0], (float)rgbaColor[1], (float)rgbaColor[2], (float)rgbaColor[3]};
TinyRendererObjectArray* visuals = *ptrptr;
if ((bodyUniqueId == visuals->m_objectUniqueId) && (linkIndex == visuals->m_linkIndex))
{

View File

@@ -39,12 +39,8 @@ project ("pybullet_tinyRendererPlugin")
"../../../ThirdPartyLibs/Wavefront/tiny_obj_loader.h",
"../../../ThirdPartyLibs/stb_image/stb_image.cpp",
"../../../ThirdPartyLibs/stb_image/stb_image.h",
"../../../ThirdPartyLibs/tinyxml/tinystr.cpp",
"../../../ThirdPartyLibs/tinyxml/tinystr.h",
"../../../ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../../../ThirdPartyLibs/tinyxml/tinyxml.h",
"../../../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../../../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../../../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../../../ThirdPartyLibs/tinyxml2/tinyxml2.h",
"../../../OpenGLWindow/SimpleCamera.cpp",
"../../../OpenGLWindow/SimpleCamera.h",
"../../../Utils/b3Clock.cpp",

View File

@@ -91,10 +91,7 @@ myfiles =
"../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
"../Importers/ImportColladaDemo/ColladaGraphicsInstance.h",
"../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../ThirdPartyLibs/tinyxml/tinystr.cpp",
"../ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../ThirdPartyLibs/stb_image/stb_image.cpp",

View File

@@ -132,10 +132,7 @@ myfiles =
"../../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
"../../Importers/ImportColladaDemo/ColladaGraphicsInstance.h",
"../../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../../ThirdPartyLibs/tinyxml/tinystr.cpp",
"../../ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../../ThirdPartyLibs/stb_image/stb_image.cpp",
}

View File

@@ -126,10 +126,7 @@ myfiles =
"../../Importers/ImportColladaDemo/LoadMeshFromCollada.cpp",
"../../Importers/ImportColladaDemo/ColladaGraphicsInstance.h",
"../../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp",
"../../ThirdPartyLibs/tinyxml/tinystr.cpp",
"../../ThirdPartyLibs/tinyxml/tinyxml.cpp",
"../../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp",
"../../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp",
"../../ThirdPartyLibs/tinyxml2/tinyxml2.cpp",
"../../Importers/ImportMeshUtility/b3ImportMeshUtility.cpp",
"../../ThirdPartyLibs/stb_image/stb_image.cpp",
}

View File

@@ -169,7 +169,7 @@ public:
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
{
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
//if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
{
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());

View File

@@ -28,9 +28,12 @@
#include "LinearMath/btIDebugDraw.h"
int gSharedMemoryKey = -1;
int gDebugDrawFlags = 0;
bool gDisplayDistortion = false;
bool gDisableDesktopGL = false;
static int gDebugDrawFlags = 0;
static bool gDisplayDistortion = false;
static bool gDisableDesktopGL = false;
static int maxNumObjectCapacity = 128 * 1024;
static int maxShapeCapacityInBytes = 128 * 1024 * 1024;
#include <stdio.h>
@@ -59,6 +62,9 @@ static vr::VRControllerState_t sPrevStates[vr::k_unMaxTrackedDeviceCount] = { 0
#ifdef _WIN32
#include <Windows.h>
#endif
#ifdef __linux__
#define APIENTRY
#endif
void ThreadSleep( unsigned long nMilliseconds )
{
@@ -474,7 +480,8 @@ bool CMainApplication::BInit()
SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
*/
m_app = new SimpleOpenGL3App("SimpleOpenGL3App",m_nWindowWidth,m_nWindowHeight,true);
m_app = new SimpleOpenGL3App("SimpleOpenGL3App",m_nWindowWidth,m_nWindowHeight,true, maxNumObjectCapacity, maxShapeCapacityInBytes);
sGuiPtr = new OpenGLGuiHelper(m_app,false);
@@ -1804,13 +1811,11 @@ void CMainApplication::RenderStereoTargets()
}
glBindFramebuffer( GL_FRAMEBUFFER, leftEyeDesc.m_nRenderFramebufferId );
glViewport(0, 0, m_nRenderWidth, m_nRenderHeight );
m_app->m_window->startRendering();
glViewport(0, 0, m_nRenderWidth, m_nRenderHeight );
RenderScene( vr::Eye_Left );
@@ -1863,9 +1868,9 @@ void CMainApplication::RenderStereoTargets()
}
glBindFramebuffer( GL_FRAMEBUFFER, rightEyeDesc.m_nRenderFramebufferId );
glViewport(0, 0, m_nRenderWidth, m_nRenderHeight );
m_app->m_window->startRendering();
glViewport(0, 0, m_nRenderWidth, m_nRenderHeight );
RenderScene( vr::Eye_Right );
@@ -2081,6 +2086,7 @@ void CMainApplication::UpdateHMDMatrixPose()
case vr::TrackedDeviceClass_HMD: m_rDevClassChar[nDevice] = 'H'; break;
case vr::TrackedDeviceClass_Invalid: m_rDevClassChar[nDevice] = 'I'; break;
case vr::TrackedDeviceClass_TrackingReference: m_rDevClassChar[nDevice] = 'T'; break;
case vr::TrackedDeviceClass_GenericTracker: m_rDevClassChar[nDevice] = 'G'; break;
default: m_rDevClassChar[nDevice] = '?'; break;
}
}
@@ -2352,7 +2358,10 @@ int main(int argc, char *argv[])
b3ChromeUtilsEnableProfiling();
}
args.GetCmdLineArgument("max_num_object_capacity", maxNumObjectCapacity);
args.GetCmdLineArgument("max_shape_capacity_in_bytes", maxShapeCapacityInBytes);
args.GetCmdLineArgument("shared_memory_key", gSharedMemoryKey);
#ifdef BT_USE_CUSTOM_PROFILER
b3SetCustomEnterProfileZoneFunc(dcEnter);
b3SetCustomLeaveProfileZoneFunc(dcLeave);

View File

@@ -22,7 +22,13 @@
#include "third_party/GL/gl/include/GL/gl.h"
#include "third_party/GL/gl/include/GL/glext.h"
#else
#ifdef BT_NO_GLAD
#include <GL/glew.h>
#else
#include "glad/glad.h"
#endif
#endif //NO_GLEW
#endif //GLEW_STATIC
#endif//(__APPLE__)

View File

@@ -4,6 +4,12 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef __linux__
#define stricmp strcasecmp
#define strnicmp strncasecmp
#endif
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------

View File

@@ -1,111 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef TIXML_USE_STL
#include "tinystr.h"
// Error value for find primitive
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
// Null rep.
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
void TiXmlString::reserve (size_type cap)
{
if (cap > capacity())
{
TiXmlString tmp;
tmp.init(length(), cap);
memcpy(tmp.start(), data(), length());
swap(tmp);
}
}
TiXmlString& TiXmlString::assign(const char* str, size_type len)
{
size_type cap = capacity();
if (len > cap || cap > 3*(len + 8))
{
TiXmlString tmp;
tmp.init(len);
memcpy(tmp.start(), str, len);
swap(tmp);
}
else
{
memmove(start(), str, len);
set_size(len);
}
return *this;
}
TiXmlString& TiXmlString::append(const char* str, size_type len)
{
size_type newsize = length() + len;
if (newsize > capacity())
{
reserve (newsize + capacity());
}
memmove(finish(), str, len);
set_size(newsize);
return *this;
}
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
{
TiXmlString tmp;
tmp.reserve(a.length() + b.length());
tmp += a;
tmp += b;
return tmp;
}
TiXmlString operator + (const TiXmlString & a, const char* b)
{
TiXmlString tmp;
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
tmp.reserve(a.length() + b_len);
tmp += a;
tmp.append(b, b_len);
return tmp;
}
TiXmlString operator + (const char* a, const TiXmlString & b)
{
TiXmlString tmp;
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
tmp.reserve(a_len + b.length());
tmp.append(a, a_len);
tmp += b;
return tmp;
}
#endif // TIXML_USE_STL

View File

@@ -1,305 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef TIXML_USE_STL
#ifndef TIXML_STRING_INCLUDED
#define TIXML_STRING_INCLUDED
#include <assert.h>
#include <string.h>
/* The support for explicit isn't that universal, and it isn't really
required - it is used to check that the TiXmlString class isn't incorrectly
used. Be nice to old compilers and macro it here:
*/
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
// Microsoft visual studio, version 6 and higher.
#define TIXML_EXPLICIT explicit
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
// GCC version 3 and higher.s
#define TIXML_EXPLICIT explicit
#else
#define TIXML_EXPLICIT
#endif
/*
TiXmlString is an emulation of a subset of the std::string template.
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
Only the member functions relevant to the TinyXML project have been implemented.
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
a string and there's no more room, we allocate a buffer twice as big as we need.
*/
class TiXmlString
{
public :
// The size type used
typedef size_t size_type;
// Error value for find primitive
static const size_type npos; // = -1;
// TiXmlString empty constructor
TiXmlString () : rep_(&nullrep_)
{
}
// TiXmlString copy constructor
TiXmlString ( const TiXmlString & copy) : rep_(0)
{
init(copy.length());
memcpy(start(), copy.data(), length());
}
// TiXmlString constructor, based on a string
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
{
init( static_cast<size_type>( strlen(copy) ));
memcpy(start(), copy, length());
}
// TiXmlString constructor, based on a string
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
{
init(len);
memcpy(start(), str, len);
}
// TiXmlString destructor
~TiXmlString ()
{
quit();
}
TiXmlString& operator = (const char * copy)
{
return assign( copy, (size_type)strlen(copy));
}
TiXmlString& operator = (const TiXmlString & copy)
{
return assign(copy.start(), copy.length());
}
// += operator. Maps to append
TiXmlString& operator += (const char * suffix)
{
return append(suffix, static_cast<size_type>( strlen(suffix) ));
}
// += operator. Maps to append
TiXmlString& operator += (char single)
{
return append(&single, 1);
}
// += operator. Maps to append
TiXmlString& operator += (const TiXmlString & suffix)
{
return append(suffix.data(), suffix.length());
}
// Convert a TiXmlString into a null-terminated char *
const char * c_str () const { return rep_->str; }
// Convert a TiXmlString into a char * (need not be null terminated).
const char * data () const { return rep_->str; }
// Return the length of a TiXmlString
size_type length () const { return rep_->size; }
// Alias for length()
size_type size () const { return rep_->size; }
// Checks if a TiXmlString is empty
bool empty () const { return rep_->size == 0; }
// Return capacity of string
size_type capacity () const { return rep_->capacity; }
// single char extraction
const char& at (size_type index) const
{
assert( index < length() );
return rep_->str[ index ];
}
// [] operator
char& operator [] (size_type index) const
{
assert( index < length() );
return rep_->str[ index ];
}
// find a char in a string. Return TiXmlString::npos if not found
size_type find (char lookup) const
{
return find(lookup, 0);
}
// find a char in a string from an offset. Return TiXmlString::npos if not found
size_type find (char tofind, size_type offset) const
{
if (offset >= length()) return npos;
for (const char* p = c_str() + offset; *p != '\0'; ++p)
{
if (*p == tofind) return static_cast< size_type >( p - c_str() );
}
return npos;
}
void clear ()
{
//Lee:
//The original was just too strange, though correct:
// TiXmlString().swap(*this);
//Instead use the quit & re-init:
quit();
init(0,0);
}
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
function DOES NOT clear the content of the TiXmlString if any exists.
*/
void reserve (size_type cap);
TiXmlString& assign (const char* str, size_type len);
TiXmlString& append (const char* str, size_type len);
void swap (TiXmlString& other)
{
Rep* r = rep_;
rep_ = other.rep_;
other.rep_ = r;
}
private:
void init(size_type sz) { init(sz, sz); }
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
char* start() const { return rep_->str; }
char* finish() const { return rep_->str + rep_->size; }
struct Rep
{
size_type size, capacity;
char str[1];
};
void init(size_type sz, size_type cap)
{
if (cap)
{
// Lee: the original form:
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
// doesn't work in some cases of new being overloaded. Switching
// to the normal allocation, although use an 'int' for systems
// that are overly picky about structure alignment.
const size_type bytesNeeded = sizeof(Rep) + cap;
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
rep_->str[ rep_->size = sz ] = '\0';
rep_->capacity = cap;
}
else
{
rep_ = &nullrep_;
}
}
void quit()
{
if (rep_ != &nullrep_)
{
// The rep_ is really an array of ints. (see the allocator, above).
// Cast it back before delete, so the compiler won't incorrectly call destructors.
delete [] ( reinterpret_cast<int*>( rep_ ) );
}
}
Rep * rep_;
static Rep nullrep_;
} ;
inline bool operator == (const TiXmlString & a, const TiXmlString & b)
{
return ( a.length() == b.length() ) // optimization on some platforms
&& ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare
}
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
{
return strcmp(a.c_str(), b.c_str()) < 0;
}
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
TiXmlString operator + (const TiXmlString & a, const char* b);
TiXmlString operator + (const char* a, const TiXmlString & b);
/*
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
Only the operators that we need for TinyXML have been developped.
*/
class TiXmlOutStream : public TiXmlString
{
public :
// TiXmlOutStream << operator.
TiXmlOutStream & operator << (const TiXmlString & in)
{
*this += in;
return *this;
}
// TiXmlOutStream << operator.
TiXmlOutStream & operator << (const char * in)
{
*this += in;
return *this;
}
} ;
#endif // TIXML_STRING_INCLUDED
#endif // TIXML_USE_STL

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#include "tinyxml.h"
// The goal of the seperate error file is to make the first
// step towards localization. tinyxml (currently) only supports
// english error messages, but the could now be translated.
//
// It also cleans up the code a bit.
//
const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"Error parsing Element.",
"Failed to read Element name",
"Error reading Element value.",
"Error reading Attributes.",
"Error: empty tag.",
"Error reading end tag.",
"Error parsing Unknown.",
"Error parsing Comment.",
"Error parsing Declaration.",
"Error document empty.",
"Error null (0) or unexpected EOF found in input stream.",
"Error parsing CDATA.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -313,11 +313,11 @@ void Dof6ConstraintTutorial::initPhysics()
#ifdef USE_6DOF2
constraint->enableMotor(5,true);
constraint->setTargetVelocity(5,3.f);
constraint->setMaxMotorForce(5,10.f);
constraint->setMaxMotorForce(5,600.f);
#else
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
#endif
constraint->setDbgDrawSize(btScalar(2.f));
m_dynamicsWorld->addConstraint(constraint, true);
@@ -348,13 +348,13 @@ void Dof6ConstraintTutorial::initPhysics()
#ifdef USE_6DOF2
constraint->enableMotor(5,true);
constraint->setTargetVelocity(5,3.f);
constraint->setMaxMotorForce(5,10.f);
constraint->setMaxMotorForce(5,600.f);
constraint->setServo(5,true);
constraint->setServoTarget(5, M_PI_2);
#else
constraint->getRotationalLimitMotor(2)->m_enableMotor = true;
constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10;
constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f;
//servo motor is not implemented in 6dofspring constraint
#endif
constraint->setDbgDrawSize(btScalar(2.f));

View File

@@ -54,10 +54,7 @@ SET(RobotSimulator_SRCS
../../examples/Utils/b3ResourcePath.h
../../examples/Utils/RobotLoggingUtil.cpp
../../examples/Utils/RobotLoggingUtil.h
../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
../../examples/ThirdPartyLibs/stb_image/stb_image.cpp

View File

@@ -64,10 +64,7 @@ SET(pybullet_SRCS
../../examples/Utils/RobotLoggingUtil.cpp
../../examples/Utils/RobotLoggingUtil.h
../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp
../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp
../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp
../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h
../../examples/ThirdPartyLibs/stb_image/stb_image.cpp

View File

@@ -0,0 +1,75 @@
import pybullet as p
import time
import math
def getRayFromTo(mouseX,mouseY):
width, height, viewMat, projMat, cameraUp, camForward, horizon,vertical, _,_,dist, camTarget = p.getDebugVisualizerCamera()
camPos = [camTarget[0] - dist*camForward[0],camTarget[1] - dist*camForward[1],camTarget[2] - dist*camForward[2]]
farPlane = 10000
rayForward = [(camTarget[0]-camPos[0]),(camTarget[1]-camPos[1]),(camTarget[2]-camPos[2])]
invLen = farPlane*1./(math.sqrt(rayForward[0]*rayForward[0]+rayForward[1]*rayForward[1]+rayForward[2]*rayForward[2]))
rayForward = [invLen*rayForward[0],invLen*rayForward[1],invLen*rayForward[2]]
rayFrom = camPos
oneOverWidth = float(1)/float(width)
oneOverHeight = float(1)/float(height)
dHor = [horizon[0] * oneOverWidth,horizon[1] * oneOverWidth,horizon[2] * oneOverWidth]
dVer = [vertical[0] * oneOverHeight,vertical[1] * oneOverHeight,vertical[2] * oneOverHeight]
rayToCenter=[rayFrom[0]+rayForward[0],rayFrom[1]+rayForward[1],rayFrom[2]+rayForward[2]]
rayTo = [rayFrom[0]+rayForward[0] - 0.5 * horizon[0] + 0.5 * vertical[0]+float(mouseX)*dHor[0]-float(mouseY)*dVer[0],
rayFrom[1]+rayForward[1] - 0.5 * horizon[1] + 0.5 * vertical[1]+float(mouseX)*dHor[1]-float(mouseY)*dVer[1],
rayFrom[2]+rayForward[2] - 0.5 * horizon[2] + 0.5 * vertical[2]+float(mouseX)*dHor[2]-float(mouseY)*dVer[2]]
return rayFrom,rayTo
cid = p.connect(p.SHARED_MEMORY)
if (cid<0):
p.connect(p.GUI)
p.setPhysicsEngineParameter(numSolverIterations=10)
p.setTimeStep(1./120.)
logId = p.startStateLogging(p.STATE_LOGGING_PROFILE_TIMINGS, "visualShapeBench.json")
#useMaximalCoordinates is much faster then the default reduced coordinates (Featherstone)
p.loadURDF("plane_transparent.urdf", useMaximalCoordinates=True)
#disable rendering during creation.
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,0)
p.configureDebugVisualizer(p.COV_ENABLE_PLANAR_REFLECTION,1)
p.configureDebugVisualizer(p.COV_ENABLE_GUI,0)
#disable tinyrenderer, software (CPU) renderer, we don't use it here
p.configureDebugVisualizer(p.COV_ENABLE_TINY_RENDERER,0)
shift = [0,-0.02,0]
meshScale=[0.1,0.1,0.1]
#the visual shape and collision shape can be re-used by all createMultiBody instances (instancing)
visualShapeId = p.createVisualShape(shapeType=p.GEOM_MESH,fileName="duck.obj", rgbaColor=[1,1,1,1], specularColor=[0.4,.4,0], visualFramePosition=shift, meshScale=meshScale)
collisionShapeId = p.createCollisionShape(shapeType=p.GEOM_MESH, fileName="duck_vhacd.obj", collisionFramePosition=shift,meshScale=meshScale)
rangex = 3
rangey = 3
for i in range (rangex):
for j in range (rangey ):
p.createMultiBody(baseMass=1,baseInertialFramePosition=[0,0,0],baseCollisionShapeIndex=collisionShapeId, baseVisualShapeIndex = visualShapeId, basePosition = [((-rangex/2)+i)*meshScale[0]*2,(-rangey/2+j)*meshScale[1]*2,1], useMaximalCoordinates=True)
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING,1)
p.stopStateLogging(logId)
p.setGravity(0,0,-10)
p.setRealTimeSimulation(1)
colors = [[1,0,0,1],[0,1,0,1],[0,0,1,1],[1,1,1,1]]
currentColor = 0
while (1):
mouseEvents = p.getMouseEvents()
for e in mouseEvents:
if ((e[0] == 2) and (e[3]==0) and (e[4]& p.KEY_WAS_TRIGGERED)):
mouseX = e[1]
mouseY = e[2]
rayFrom,rayTo=getRayFromTo(mouseX,mouseY)
rayInfo = p.rayTest(rayFrom,rayTo)
#p.addUserDebugLine(rayFrom,rayTo,[1,0,0],3)
for l in range(len(rayInfo)):
hit = rayInfo[l]
objectUid = hit[0]
if (objectUid>=1):
#p.removeBody(objectUid)
p.changeVisualShape(objectUid,-1,rgbaColor=colors[currentColor])
currentColor+=1
if (currentColor>=len(colors)):
currentColor=0

View File

@@ -40,8 +40,8 @@ meshScale=[0.1,0.1,0.1]
visualShapeId = p.createVisualShape(shapeType=p.GEOM_MESH,fileName="duck.obj", rgbaColor=[1,1,1,1], specularColor=[0.4,.4,0], visualFramePosition=shift, meshScale=meshScale)
collisionShapeId = p.createCollisionShape(shapeType=p.GEOM_MESH, fileName="duck_vhacd.obj", collisionFramePosition=shift,meshScale=meshScale)
rangex = 32
rangey = 32
rangex = 5
rangey = 5
for i in range (rangex):
for j in range (rangey ):
p.createMultiBody(baseMass=1,baseInertialFramePosition=[0,0,0],baseCollisionShapeIndex=collisionShapeId, baseVisualShapeIndex = visualShapeId, basePosition = [((-rangex/2)+i)*meshScale[0]*2,(-rangey/2+j)*meshScale[1]*2,1], useMaximalCoordinates=True)
@@ -65,7 +65,7 @@ while (1):
for l in range(len(rayInfo)):
hit = rayInfo[l]
objectUid = hit[0]
if (objectUid>=0):
if (objectUid>=1):
#p.removeBody(objectUid)
p.changeVisualShape(objectUid,-1,rgbaColor=colors[currentColor])
currentColor+=1

View File

@@ -0,0 +1,61 @@
import pybullet as p
import pybullet_data
import time
p.connect(p.GUI)
p.setAdditionalSearchPath(pybullet_data.getDataPath())
p.loadSDF("stadium.sdf")
p.setGravity(0,0,-10)
objects = p.loadMJCF("mjcf/sphere.xml")
sphere = objects[0]
p.resetBasePositionAndOrientation(sphere,[0,0,1],[0,0,0,1])
p.changeDynamics(sphere,-1,linearDamping=0.9)
p.changeVisualShape(sphere,-1,rgbaColor=[1,0,0,1])
forward = 0
turn = 0
forwardVec = [2,0,0]
cameraDistance = 1
cameraYaw = 35
cameraPitch = -35
while (1):
spherePos, orn = p.getBasePositionAndOrientation(sphere)
cameraTargetPosition = spherePos
p.resetDebugVisualizerCamera(cameraDistance,cameraYaw,cameraPitch,cameraTargetPosition)
camInfo = p.getDebugVisualizerCamera()
camForward = camInfo[5]
keys = p.getKeyboardEvents()
for k,v in keys.items():
if (k == p.B3G_RIGHT_ARROW and (v&p.KEY_WAS_TRIGGERED)):
turn = -0.5
if (k == p.B3G_RIGHT_ARROW and (v&p.KEY_WAS_RELEASED)):
turn = 0
if (k == p.B3G_LEFT_ARROW and (v&p.KEY_WAS_TRIGGERED)):
turn = 0.5
if (k == p.B3G_LEFT_ARROW and (v&p.KEY_WAS_RELEASED)):
turn = 0
if (k == p.B3G_UP_ARROW and (v&p.KEY_WAS_TRIGGERED)):
forward=1
if (k == p.B3G_UP_ARROW and (v&p.KEY_WAS_RELEASED)):
forward=0
if (k == p.B3G_DOWN_ARROW and (v&p.KEY_WAS_TRIGGERED)):
forward=-1
if (k == p.B3G_DOWN_ARROW and (v&p.KEY_WAS_RELEASED)):
forward=0
force = [forward*camForward[0],forward*camForward[1],0]
cameraYaw = cameraYaw+turn
if (forward):
p.applyExternalForce(sphere,-1, force , spherePos, flags = p.WORLD_FRAME )
p.stepSimulation()
time.sleep(1./240.)

View File

@@ -8,6 +8,15 @@ def getJointStates(robot):
joint_torques = [state[3] for state in joint_states]
return joint_positions, joint_velocities, joint_torques
def getMotorJointStates(robot):
joint_states = p.getJointStates(robot, range(p.getNumJoints(robot)))
joint_infos = [p.getJointInfo(robot, i) for i in range(p.getNumJoints(robot))]
joint_states = [j for j, i in zip(joint_states, joint_infos) if i[3] > -1]
joint_positions = [state[0] for state in joint_states]
joint_velocities = [state[1] for state in joint_states]
joint_torques = [state[3] for state in joint_states]
return joint_positions, joint_velocities, joint_torques
def setJointPosition(robot, position, kp=1.0, kv=0.3):
num_joints = p.getNumJoints(robot)
zero_vec = [0.0] * num_joints
@@ -20,47 +29,60 @@ def setJointPosition(robot, position, kp=1.0, kv=0.3):
"Expected torque vector of "
"length {}, got {}".format(num_joints, len(torque)))
def multiplyJacobian(jacobian, vector):
def multiplyJacobian(robot, jacobian, vector):
result = [0.0, 0.0, 0.0]
i = 0
for c in range(len(vector)):
for r in range(3):
result[r] += jacobian[r][c] * vector[c]
if p.getJointInfo(robot, c)[3] > -1:
for r in range(3):
result[r] += jacobian[r][i] * vector[c]
i += 1
return result
clid = p.connect(p.SHARED_MEMORY)
if (clid<0):
p.connect(p.DIRECT)
time_step = 0.001
gravity_constant = -9.81
p.resetSimulation()
p.setTimeStep(time_step)
p.setGravity(0.0, 0.0, gravity_constant)
p.loadURDF("plane.urdf",[0,0,-0.3])
kukaId = p.loadURDF("kuka_iiwa/model.urdf",[0,0,0])
kukaId = p.loadURDF("TwoJointRobot_w_fixedJoints.urdf", useFixedBase=True)
#kukaId = p.loadURDF("TwoJointRobot_w_fixedJoints.urdf",[0,0,0])
#kukaId = p.loadURDF("kuka_iiwa/model.urdf",[0,0,0])
#kukaId = p.loadURDF("kuka_lwr/kuka.urdf",[0,0,0])
#kukaId = p.loadURDF("humanoid/nao.urdf",[0,0,0])
p.resetBasePositionAndOrientation(kukaId,[0,0,0],[0,0,0,1])
kukaEndEffectorIndex = 6
numJoints = p.getNumJoints(kukaId)
if (numJoints!=7):
exit()
kukaEndEffectorIndex = numJoints - 1
# Set a joint target for the position control and step the sim.
setJointPosition(kukaId, [0.1] * p.getNumJoints(kukaId))
setJointPosition(kukaId, [0.1] * numJoints)
p.stepSimulation()
# Get the joint and link state directly from Bullet.
pos, vel, torq = getJointStates(kukaId)
mpos, mvel, mtorq = getMotorJointStates(kukaId)
result = p.getLinkState(kukaId, kukaEndEffectorIndex, computeLinkVelocity=1, computeForwardKinematics=1)
link_trn, link_rot, com_trn, com_rot, frame_pos, frame_rot, link_vt, link_vr = result
# Get the Jacobians for the CoM of the end-effector link.
# Note that in this example com_rot = identity, and we would need to use com_rot.T * com_trn.
# The localPosition is always defined in terms of the link frame coordinates.
zero_vec = [0.0] * numJoints
jac_t, jac_r = p.calculateJacobian(kukaId, kukaEndEffectorIndex, com_trn, pos, zero_vec, zero_vec)
zero_vec = [0.0] * len(mpos)
jac_t, jac_r = p.calculateJacobian(kukaId, kukaEndEffectorIndex, com_trn, mpos, zero_vec, zero_vec)
print ("Link linear velocity of CoM from getLinkState:")
print (link_vt)
print ("Link linear velocity of CoM from linearJacobian * q_dot:")
print (multiplyJacobian(jac_t, vel))
print (multiplyJacobian(kukaId, jac_t, vel))
print ("Link angular velocity of CoM from getLinkState:")
print (link_vr)
print ("Link angular velocity of CoM from angularJacobian * q_dot:")
print (multiplyJacobian(jac_r, vel))
print (multiplyJacobian(kukaId, jac_r, vel))

View File

@@ -0,0 +1,15 @@
import pybullet as p
import pybullet
import time
p.connect(p.GUI)
p.loadURDF("toys/concave_box.urdf")
p.setGravity(0,0,-10)
for i in range (10):
p.loadURDF("sphere_1cm.urdf",[i*0.02,0,0.5])
p.loadURDF("duck_vhacd.urdf")
timeStep = 1./240.
p.setTimeStep(timeStep)
while (1):
p.stepSimulation()
time.sleep(timeStep)

View File

@@ -1,6 +1,6 @@
<?xml version="0.0" ?>
<robot name="cube.urdf">
<link name="baseLink">
<robot name="floor">
<link name="floor">
<inertial>
<origin rpy="0 0 0" xyz="0 0 0"/>
<mass value=".0"/>

Some files were not shown because too many files have changed in this diff Show More