upgrade from tinyxml to tinyxml2

This commit is contained in:
erwincoumans
2018-04-12 00:09:44 -07:00
parent 2bc246b0b1
commit 9c77e07494
39 changed files with 5439 additions and 11941 deletions

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

@@ -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,9 +874,9 @@ void btBulletXmlWorldImporter::auto_serialize(TiXmlNode* pParent)
bool btBulletXmlWorldImporter::loadFile(const char* fileName)
{
TiXmlDocument doc(fileName);
XMLDocument doc;
bool loadOkay = doc.LoadFile();
bool loadOkay = doc.LoadFile(fileName);
//dump_to_stdout(&doc,0);

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