aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml')
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnJointRepXSerializer.cpp137
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnPxStreamOperators.h134
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX1_0Defaults.h245
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_1Defaults.h274
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_2Defaults.h313
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCollection.h173
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.cpp1158
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.h156
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXSerializerImpl.h90
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.cpp444
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.h53
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnSimpleXmlWriter.h257
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlDeserializer.h188
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlImpl.h242
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryAllocator.h129
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPool.h373
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPoolStreams.h173
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlReader.h130
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerialization.cpp834
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerializer.h117
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSimpleXmlWriter.h215
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlStringToType.h275
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorReader.h889
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorWriter.h765
-rw-r--r--PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlWriter.h57
25 files changed, 7821 insertions, 0 deletions
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnJointRepXSerializer.cpp b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnJointRepXSerializer.cpp
new file mode 100644
index 00000000..94d60453
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnJointRepXSerializer.cpp
@@ -0,0 +1,137 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#include "PxMetaDataObjects.h"
+#include "PxExtensionMetaDataObjects.h"
+#include "ExtJointMetaDataExtensions.h"
+#include "SnRepXSerializerImpl.h"
+#include "PxJointRepXSerializer.h"
+
+namespace physx {
+
+ template<typename TJointType>
+ inline TJointType* createJoint( PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1 )
+ {
+ PX_UNUSED(physics);
+ PX_UNUSED(actor0);
+ PX_UNUSED(actor1);
+ PX_UNUSED(localFrame0);
+ PX_UNUSED(localFrame1);
+ return NULL;
+ }
+
+ template<>
+ inline PxD6Joint* createJoint<PxD6Joint>(PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1)
+ {
+ return PxD6JointCreate( physics, actor0, localFrame0, actor1, localFrame1 );
+ }
+
+ template<>
+ inline PxDistanceJoint* createJoint<PxDistanceJoint>(PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1)
+ {
+ return PxDistanceJointCreate( physics, actor0, localFrame0, actor1, localFrame1 );
+ }
+
+ template<>
+ inline PxFixedJoint* createJoint<PxFixedJoint>(PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1)
+ {
+ return PxFixedJointCreate( physics, actor0, localFrame0, actor1, localFrame1 );
+ }
+
+ template<>
+ inline PxPrismaticJoint* createJoint<PxPrismaticJoint>(PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1)
+ {
+ return PxPrismaticJointCreate( physics, actor0, localFrame0, actor1, localFrame1 );
+ }
+
+ template<>
+ inline PxRevoluteJoint* createJoint<PxRevoluteJoint>(PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1)
+ {
+ return PxRevoluteJointCreate( physics, actor0, localFrame0, actor1, localFrame1 );
+ }
+
+ template<>
+ inline PxSphericalJoint* createJoint<PxSphericalJoint>(PxPhysics& physics,
+ PxRigidActor* actor0, const PxTransform& localFrame0,
+ PxRigidActor* actor1, const PxTransform& localFrame1)
+ {
+ return PxSphericalJointCreate( physics, actor0, localFrame0, actor1, localFrame1 );
+ }
+
+ template<typename TJointType>
+ PxRepXObject PxJointRepXSerializer<TJointType>::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ PxRigidActor* actor0 = NULL;
+ PxRigidActor* actor1 = NULL;
+ PxTransform localPose0 = PxTransform(PxIdentity);
+ PxTransform localPose1 = PxTransform(PxIdentity);
+ bool ok = true;
+ if ( inReader.gotoChild( "Actors" ) )
+ {
+ ok = readReference<PxRigidActor>( inReader, *inCollection, "actor0", actor0 );
+ ok &= readReference<PxRigidActor>( inReader, *inCollection, "actor1", actor1 );
+ inReader.leaveChild();
+ }
+ TJointType* theJoint = !ok ? NULL : createJoint<TJointType>( inArgs.physics, actor0, localPose0, actor1, localPose1 );
+
+ if ( theJoint )
+ {
+ PxConstraint* constraint = theJoint->getConstraint();
+ PX_ASSERT( constraint );
+ inCollection->add( *constraint );
+ this->fileToObjectImpl( theJoint, inReader, inAllocator, inArgs, inCollection );
+ }
+ return PxCreateRepXObject(theJoint);
+ }
+
+ template<typename TJointType>
+ void PxJointRepXSerializer<TJointType>::objectToFileImpl( const TJointType* inObj, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& )
+ {
+ writeAllProperties( inObj, inWriter, inTempBuffer, *inCollection );
+ }
+
+ // explicit instantiations
+ template struct PxJointRepXSerializer<PxFixedJoint>;
+ template struct PxJointRepXSerializer<PxDistanceJoint>;
+ template struct PxJointRepXSerializer<PxD6Joint>;
+ template struct PxJointRepXSerializer<PxPrismaticJoint>;
+ template struct PxJointRepXSerializer<PxRevoluteJoint>;
+ template struct PxJointRepXSerializer<PxSphericalJoint>;
+}
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnPxStreamOperators.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnPxStreamOperators.h
new file mode 100644
index 00000000..efca5662
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnPxStreamOperators.h
@@ -0,0 +1,134 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_PXSTREAMOPERATORS_H
+#define PX_PXSTREAMOPERATORS_H
+
+#include "foundation/PxVec3.h"
+#include "foundation/PxTransform.h"
+#include "foundation/PxBounds3.h"
+#include "PxFiltering.h"
+
+#include "PsString.h"
+
+namespace physx
+{
+ static inline PxU32 strLenght( const char* inStr )
+ {
+ return inStr ? PxU32(strlen(inStr)) : 0;
+ }
+}
+
+namespace physx // ADL requires we put the operators in the same namespace as the underlying type of PxOutputStream
+{
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const char* inString )
+ {
+ if ( inString && *inString )
+ {
+ ioStream.write( inString, PxU32(strlen(inString)) );
+ }
+ return ioStream;
+ }
+
+ template<typename TDataType>
+ inline PxOutputStream& toStream( PxOutputStream& ioStream, const char* inFormat, const TDataType inData )
+ {
+ char buffer[128] = { 0 };
+ Ps::snprintf( buffer, 128, inFormat, inData );
+ ioStream << buffer;
+ return ioStream;
+ }
+
+ struct endl_obj {};
+ //static endl_obj endl;
+
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, bool inData ) { ioStream << (inData ? "true" : "false"); return ioStream; }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxI32 inData ) { return toStream( ioStream, "%d", inData ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxU16 inData ) { return toStream( ioStream, "%u", PxU32(inData) ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxU8 inData ) { return toStream( ioStream, "%u", PxU32(inData) ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, char inData ) { return toStream( ioStream, "%c", inData ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxU32 inData ) { return toStream( ioStream, "%u", inData ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxU64 inData ) { return toStream( ioStream, "%" PX_PRIu64, inData ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const void* inData ) { return ioStream << PX_PROFILE_POINTER_TO_U64( inData ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxF32 inData ) { return toStream( ioStream, "%g", PxF64(inData) ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, PxF64 inData ) { return toStream( ioStream, "%g", inData ); }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, endl_obj) { return ioStream << "\n"; }
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const PxVec3& inData )
+ {
+ ioStream << inData[0];
+ ioStream << " ";
+ ioStream << inData[1];
+ ioStream << " ";
+ ioStream << inData[2];
+ return ioStream;
+ }
+
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const PxQuat& inData )
+ {
+ ioStream << inData.x;
+ ioStream << " ";
+ ioStream << inData.y;
+ ioStream << " ";
+ ioStream << inData.z;
+ ioStream << " ";
+ ioStream << inData.w;
+ return ioStream;
+ }
+
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const PxTransform& inData )
+ {
+ ioStream << inData.q;
+ ioStream << " ";
+ ioStream << inData.p;
+ return ioStream;
+ }
+
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const PxBounds3& inData )
+ {
+ ioStream << inData.minimum;
+ ioStream << " ";
+ ioStream << inData.maximum;
+ return ioStream;
+ }
+
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, const PxFilterData& inData )
+ {
+ ioStream << inData.word0 << " " << inData.word1 << " " << inData.word2 << " " << inData.word3;
+ return ioStream;
+ }
+
+ inline PxOutputStream& operator << ( PxOutputStream& ioStream, struct PxMetaDataPlane& inData )
+ {
+ ioStream << inData.normal;
+ ioStream << " ";
+ ioStream << inData.distance;
+ return ioStream;
+ }
+}
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX1_0Defaults.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX1_0Defaults.h
new file mode 100644
index 00000000..31ad950e
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX1_0Defaults.h
@@ -0,0 +1,245 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+ DEFINE_REPX_DEFAULT_PROPERTY("PxBoxGeometry.HalfExtents", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphereGeometry.Radius", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.Scale.Scale", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.Scale.Rotation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.ConvexMesh", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.Scale.Scale", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.Scale.Rotation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.MeshFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.TriangleMesh", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightField", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.RowScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.ColumnScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightFieldFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Length", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Mass", "1000" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Speed", "10" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DynamicFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.StaticFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DynamicFrictionV", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.StaticFrictionV", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DirOfAnisotropy", "1 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.FrictionCombineMode", "eAVERAGE" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.RestitutionCombineMode", "eAVERAGE" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.LocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.SimulationFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.QueryFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.ContactOffset", "0.02" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.RestOffset", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.Flags", "eSIMULATION_SHAPE|eSCENE_QUERY_SHAPE|eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.CMassLocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.Mass", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.MassSpaceInertiaTensor", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.LinearVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.AngularVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.LinearDamping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.AngularDamping", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.MaxAngularVelocity", "7" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SleepEnergyThreshold", "0.005" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SolverIterationCounts.minPositionIters", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SolverIterationCounts.minVelocityIters", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ContactReportThreshold", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.RigidDynamicFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ParentPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ChildPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TargetOrientation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TargetVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.InternalCompliance", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ExternalCompliance", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimit.yLimit", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimit.zLimit", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimitEnabled", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimit.lower", "-0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimit.upper", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimitEnabled", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.CMassLocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.Mass", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.MassSpaceInertiaTensor", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.LinearVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.AngularVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.MaxProjectionIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SeparationTolerance", "0.1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.InternalDriveIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.ExternalDriveIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SolverIterationCounts.minPositionIters", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SolverIterationCounts.minVelocityIters", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eX", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eY", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eZ", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eTWIST", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eSWING1", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eSWING2", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Value", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Upper", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Lower", "-1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.YAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.ZAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DrivePosition", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DriveVelocity.linear", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DriveVelocity.angular", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.MinDistance", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.MaxDistance", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Tolerance", "0.025" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.DistanceJointFlags", "eMAX_DISTANCE_ENABLED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Upper", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Lower", "-1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveVelocity", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveGearRatio", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.RevoluteJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.ContactDistance", "0.01" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Upper", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Lower", "-3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.PrismaticJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.UserData", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.YAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.ZAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.SphericalJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("THEEND", "false" )
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_1Defaults.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_1Defaults.h
new file mode 100644
index 00000000..a3e52a73
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_1Defaults.h
@@ -0,0 +1,274 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Length", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Mass", "1000" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Speed", "10" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxBoxGeometry.HalfExtents", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphereGeometry.Radius", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.Scale.Scale", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.Scale.Rotation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.ConvexMesh", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.Scale.Scale", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.Scale.Rotation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.MeshFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.TriangleMesh", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightField", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.RowScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.ColumnScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightFieldFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DynamicFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.StaticFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DynamicFrictionV", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.StaticFrictionV", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DirOfAnisotropy", "1 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.FrictionCombineMode", "eAVERAGE" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.RestitutionCombineMode", "eAVERAGE" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.LocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.SimulationFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.QueryFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.ContactOffset", "0.02" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.RestOffset", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.Flags", "eSIMULATION_SHAPE|eSCENE_QUERY_SHAPE|eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.CMassLocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.Mass", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.MassSpaceInertiaTensor", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.LinearVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.AngularVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.LinearDamping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.AngularDamping", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.MaxAngularVelocity", "7" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SleepThreshold", "0.005" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SolverIterationCounts.minPositionIters", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SolverIterationCounts.minVelocityIters", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ContactReportThreshold", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.RigidDynamicFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ParentPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ChildPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TargetOrientation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TargetVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.InternalCompliance", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ExternalCompliance", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimit.yLimit", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimit.zLimit", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TangentialSpring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TangentialDamping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimitContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimitEnabled", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimit.lower", "-0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimit.upper", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimitEnabled", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimitContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.CMassLocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.Mass", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.MassSpaceInertiaTensor", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.LinearVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.AngularVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.MaxProjectionIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SeparationTolerance", "0.1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.InternalDriveIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.ExternalDriveIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SolverIterationCounts.minPositionIters", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SolverIterationCounts.minVelocityIters", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SleepThreshold", "0.005" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eX", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eY", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eZ", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eTWIST", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eSWING1", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eSWING2", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Value", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Upper", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Lower", "-1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.YAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.ZAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DrivePosition", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DriveVelocity.linear", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DriveVelocity.angular", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.MinDistance", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.MaxDistance", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Tolerance", "0.025" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.DistanceJointFlags", "eMAX_DISTANCE_ENABLED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Upper", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Lower", "-1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveVelocity", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveGearRatio", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.RevoluteJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.ContactDistance", "0.01" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Upper", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Lower", "-3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.PrismaticJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.YAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.ZAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.SphericalJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.MotionConstraintScaleBias.scale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.MotionConstraintScaleBias.bias", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.ExternalAcceleration", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.DampingCoefficient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.SolverFrequency", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.SleepLinearVelocity", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("THEEND", "false" )
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_2Defaults.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_2Defaults.h
new file mode 100644
index 00000000..f3959504
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepX3_2Defaults.h
@@ -0,0 +1,313 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Length", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Mass", "1000" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTolerancesScale.Speed", "10" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxBoxGeometry.HalfExtents", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphereGeometry.Radius", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.Scale.Scale", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.Scale.Rotation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxConvexMeshGeometry.ConvexMesh", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.Scale.Scale", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.Scale.Rotation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.MeshFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxTriangleMeshGeometry.TriangleMesh", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightField", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.RowScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.ColumnScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxHeightFieldGeometry.HeightFieldFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.DynamicFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.StaticFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.FrictionCombineMode", "eAVERAGE" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxMaterial.RestitutionCombineMode", "eAVERAGE" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.LocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.SimulationFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.QueryFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.ContactOffset", "0.02" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.RestOffset", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.Flags", "eSIMULATION_SHAPE|eSCENE_QUERY_SHAPE|eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxShape.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidStatic.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.CMassLocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.Mass", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.MassSpaceInertiaTensor", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.LinearVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.AngularVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.LinearDamping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.AngularDamping", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.MaxAngularVelocity", "7" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SleepThreshold", "0.005" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SolverIterationCounts.minPositionIters", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.SolverIterationCounts.minVelocityIters", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.ContactReportThreshold", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRigidDynamic.RigidDynamicFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ParentPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ChildPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TargetOrientation", "0 0 0 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TargetVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.InternalCompliance", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.ExternalCompliance", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimit.yLimit", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimit.zLimit", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TangentialSpring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TangentialDamping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimitContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.SwingLimitEnabled", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimit.lower", "-0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimit.upper", "0.78539816339" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimitEnabled", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationJoint.TwistLimitContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.CMassLocalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.Mass", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.MassSpaceInertiaTensor", "1 1 1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.LinearVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulationLink.AngularVelocity", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.MaxProjectionIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SeparationTolerance", "0.1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.InternalDriveIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.ExternalDriveIterations", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SolverIterationCounts.minPositionIters", "4" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SolverIterationCounts.minVelocityIters", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.SleepThreshold", "0.005" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxArticulation.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eX", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eY", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eZ", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eTWIST", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eSWING1", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Motion.eSWING2", "eLOCKED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.LinearLimit.Value", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Upper", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.TwistLimit.Lower", "-1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.YAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.SwingLimit.ZAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eX.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eY.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eZ.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSWING.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eTWIST.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.ForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.Drive.eSLERP.Flags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DrivePosition", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DriveVelocity.linear", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.DriveVelocity.angular", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxD6Joint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxFixedJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.MinDistance", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.MaxDistance", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Tolerance", "0.025" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxDistanceJoint.DistanceJointFlags", "eMAX_DISTANCE_ENABLED" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Upper", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.Limit.Lower", "-1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveVelocity", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveForceLimit", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.DriveGearRatio", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.RevoluteJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxRevoluteJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.ContactDistance", "0.01" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Upper", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.Limit.Lower", "-3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.PrismaticJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxPrismaticJoint.ProjectionAngularTolerance", "3.14159" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Actors.actor0", "8887040" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Actors.actor1", "8887456" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LocalPose.eACTOR0", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LocalPose.eACTOR1", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.BreakForce.force", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.BreakForce.torque", "3.40282e+038" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.ConstraintFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Restitution", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Spring", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.ContactDistance", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.YAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.LimitCone.ZAngle", "1.5708" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.SphericalJointFlags", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxSphericalJoint.ProjectionLinearTolerance", "1e+010" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.Name", "" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.ClientBehaviorBits", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.MotionConstraintScaleBias.scale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.MotionConstraintScaleBias.bias", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.GlobalPose", "0 0 0 1 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.ExternalAcceleration", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.DampingCoefficient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.SolverFrequency", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.SleepLinearVelocity", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.InertiaScale", "1" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.FrictionCoefficient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.DragCoefficient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxCloth.CollisionMassScale", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ExternalAcceleration", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ParticleMass", "0.001" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.Restitution", "0.5" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.DynamicFriction", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.StaticFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.SimulationFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.MaxMotionDistance", "0.06" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.RestOffset", "0.004" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ContactOffset", "0.008" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.GridSize", "0.96" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ProjectionPlane", "0 0 1 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ParticleReadDataFlags", "ePOSITION_BUFFER|eFLAGS_BUFFER" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleSystem.ParticleBaseFlags", "eCOLLISION_WITH_DYNAMIC_ACTORS|eENABLED|ePER_PARTICLE_REST_OFFSET|ePER_PARTICLE_COLLISION_CACHE_HINT")
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ActorFlags", "eVISUALIZATION" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.DominanceGroup", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.OwnerClient", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.Damping", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ExternalAcceleration", "0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ParticleMass", "0.001" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.Restitution", "0.5" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.DynamicFriction", "0.05" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.StaticFriction", "0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.SimulationFilterData", "0 0 0 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.MaxMotionDistance", "0.06" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.RestOffset", "0.004" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ContactOffset", "0.008" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.GridSize", "0.64" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ProjectionPlane", "0 0 1 0" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.Stiffness", "20" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.Viscosity", "6" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.RestParticleDistance", "0.02" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ParticleReadDataFlags", "ePOSITION_BUFFER|eFLAGS_BUFFER" )
+ DEFINE_REPX_DEFAULT_PROPERTY("PxParticleFluid.ParticleBaseFlags", "eCOLLISION_WITH_DYNAMIC_ACTORS|eENABLED|ePER_PARTICLE_REST_OFFSET|ePER_PARTICLE_COLLISION_CACHE_HINT")
+ DEFINE_REPX_DEFAULT_PROPERTY("PxAggregate.SelfCollision", "false" )
+ DEFINE_REPX_DEFAULT_PROPERTY("THEEND", "false" )
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCollection.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCollection.h
new file mode 100644
index 00000000..b479754d
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCollection.h
@@ -0,0 +1,173 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_REPXCOLLECTION_H
+#define PX_REPXCOLLECTION_H
+
+#include "common/PxTolerancesScale.h"
+#include "PxRepXSerializer.h"
+
+namespace physx { namespace Sn {
+
+ struct XmlNode;
+
+ struct RepXCollectionItem
+ {
+ PxRepXObject liveObject;
+ XmlNode* descriptor;
+ RepXCollectionItem( PxRepXObject inItem = PxRepXObject(), XmlNode* inDescriptor = NULL )
+ : liveObject( inItem )
+ , descriptor( inDescriptor )
+ {
+ }
+ };
+
+ struct RepXDefaultEntry
+ {
+ const char* name;
+ const char* value;
+ RepXDefaultEntry( const char* pn, const char* val ) : name( pn ), value( val ){}
+ };
+
+ /**
+ * The result of adding an object to the collection.
+ */
+ struct RepXAddToCollectionResult
+ {
+ enum Enum
+ {
+ Success,
+ SerializerNotFound,
+ InvalidParameters, //Null data passed in.
+ AlreadyInCollection
+ };
+
+ PxSerialObjectId collectionId;
+ Enum result;
+
+ RepXAddToCollectionResult( Enum inResult = Success, const PxSerialObjectId inId = 0 )
+ : collectionId( inId )
+ , result( inResult )
+ {
+ }
+ bool isValid() { return result == Success && collectionId != 0; }
+ };
+ /**
+ * A RepX collection contains a set of static data objects that can be transformed
+ * into live objects. It uses RepX serializer to do two transformations:
+ * live object <-> collection object (descriptor)
+ * collection object <-> file system.
+ *
+ * A live object is considered to be something live in the physics
+ * world such as a material or a rigidstatic.
+ *
+ * A collection object is a piece of data from which a live object
+ * of identical characteristics can be created.
+ *
+ * Clients need to pass PxCollection so that objects can resolve
+ * references. In addition, objects must be added in an order such that
+ * references can be resolved in the first place. So objects must be added
+ * to the collection *after* objects they are dependent upon.
+ *
+ * When deserializing from a file, the collection will allocate char*'s that will
+ * not be freed when the collection itself is freed. The user must be responsible
+ * for these character allocations.
+ */
+ class RepXCollection
+ {
+ protected:
+ virtual ~RepXCollection(){}
+
+ public:
+ virtual void destroy() = 0;
+
+ /**
+ * Set the scale on this collection. The scale is saved with the collection.
+ *
+ * If the scale wasn't set, it will be invalid.
+ */
+ virtual void setTolerancesScale( const PxTolerancesScale& inScale ) = 0;
+
+ /**
+ * Get the scale that was set at collection creation time or at load time.
+ * If this is a loaded file and the source data does not contain a scale
+ * this value will be invalid (PxTolerancesScale::isValid()).
+ */
+ virtual PxTolerancesScale getTolerancesScale() const = 0;
+
+ /**
+ * Set the up vector on this collection. The up vector is saved with the collection.
+ *
+ * If the up vector wasn't set, it will be (0,0,0).
+ */
+ virtual void setUpVector( const PxVec3& inUpVector ) = 0;
+
+ /**
+ * If the up vector wasn't set, it will be (0,0,0). Else this will be the up vector
+ * optionally set when the collection was created.
+ */
+ virtual PxVec3 getUpVector() const = 0;
+
+ virtual const char* getVersion() = 0;
+ static const char* getLatestVersion();
+
+ //Necessary accessor functions for translation/upgrading.
+ virtual const RepXCollectionItem* begin() const = 0;
+ virtual const RepXCollectionItem* end() const = 0;
+
+
+ //Performs a deep copy of the repx node.
+ virtual XmlNode* copyRepXNode( const XmlNode* srcNode ) = 0;
+
+ virtual void addCollectionItem( RepXCollectionItem inItem ) = 0;
+
+ //Create a new repx node with this name. Its value is unset.
+ virtual XmlNode& createRepXNode( const char* name ) = 0;
+
+ virtual RepXCollection& createCollection( const char* inVersionStr ) = 0;
+ //Release this when finished.
+ virtual XmlReaderWriter& createNodeEditor() = 0;
+
+ virtual PxAllocatorCallback& getAllocator() = 0;
+
+ virtual bool instantiateCollection( PxRepXInstantiationArgs& inArgs, PxCollection& inPxCollection ) = 0;
+
+
+ virtual RepXAddToCollectionResult addRepXObjectToCollection( const PxRepXObject& inObject, PxCollection* inCollection, PxRepXInstantiationArgs& inArgs ) = 0;
+
+ /**
+ * Save this collection out to a file stream. Uses the RepX serialize to perform
+ * collection object->file conversions.
+ *
+ * /param[in] inStream Write-only stream to save collection out to.
+ */
+ virtual void save( PxOutputStream& inStream ) = 0;
+ };
+} }
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.cpp b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.cpp
new file mode 100644
index 00000000..104e521c
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.cpp
@@ -0,0 +1,1158 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#include "PxPhysicsAPI.h"
+#include "PxMetaDataObjects.h"
+#include "CmIO.h"
+#include "SnPxStreamOperators.h"
+#include "PsUtilities.h"
+#include "SnXmlImpl.h"
+#include "SnXmlSerializer.h"
+#include "SnXmlDeserializer.h"
+#include "SnRepXCoreSerializer.h"
+
+using namespace physx::Sn;
+namespace physx {
+ typedef PxProfileHashMap< const PxSerialObjectId, const PxArticulationLink* > TArticulationLinkLinkMap;
+ typedef PxReadOnlyPropertyInfo<PxPropertyInfoName::PxArticulationLink_InboundJoint, PxArticulationLink, PxArticulationJoint *> TIncomingJointPropType;
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxMaterial
+ //*************************************************************
+ PxMaterial* PxMaterialRepXSerializer::allocateObject( PxRepXInstantiationArgs& inArgs )
+ {
+ return inArgs.physics.createMaterial(0, 0, 0);
+ }
+
+ PxRepXObject PxShapeRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ PxProfileAllocatorWrapper wrapper( inAllocator.getAllocator() );
+ TReaderNameStack names( wrapper );
+ PxProfileArray<PxU32> contexts( wrapper );
+ bool hadError = false;
+ RepXVisitorReader<PxShape> theVisitor( names, contexts, inArgs, inReader, NULL, inAllocator, *inCollection, hadError );
+
+ Ps::Array<PxMaterial*> materials;
+ PxGeometry* geometry = NULL;
+ parseShape( theVisitor, geometry, materials );
+ if(hadError)
+ return PxRepXObject();
+ PxShape *theShape = inArgs.physics.createShape( *geometry, materials.begin(), Ps::to16(materials.size()) );
+
+ switch(geometry->getType())
+ {
+ case PxGeometryType::eSPHERE :
+ static_cast<PxSphereGeometry*>(geometry)->~PxSphereGeometry();
+ break;
+ case PxGeometryType::ePLANE :
+ static_cast<PxPlaneGeometry*>(geometry)->~PxPlaneGeometry();
+ break;
+ case PxGeometryType::eCAPSULE :
+ static_cast<PxCapsuleGeometry*>(geometry)->~PxCapsuleGeometry();
+ break;
+ case PxGeometryType::eBOX :
+ static_cast<PxBoxGeometry*>(geometry)->~PxBoxGeometry();
+ break;
+ case PxGeometryType::eCONVEXMESH :
+ static_cast<PxConvexMeshGeometry*>(geometry)->~PxConvexMeshGeometry();
+ break;
+ case PxGeometryType::eTRIANGLEMESH :
+ static_cast<PxTriangleMeshGeometry*>(geometry)->~PxTriangleMeshGeometry();
+ break;
+ case PxGeometryType::eHEIGHTFIELD :
+ static_cast<PxHeightFieldGeometry*>(geometry)->~PxHeightFieldGeometry();
+ break;
+
+ case PxGeometryType::eGEOMETRY_COUNT:
+ case PxGeometryType::eINVALID:
+ PX_ASSERT(0);
+ }
+ inAllocator.getAllocator().deallocate(geometry);
+
+ bool ret = readAllProperties( inArgs, inReader, theShape, inAllocator, *inCollection );
+
+ return ret ? PxCreateRepXObject(theShape) : PxRepXObject();
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxTriangleMesh
+ //*************************************************************
+
+ template<typename TTriIndexElem>
+ inline void writeTriangle( MemoryBuffer& inTempBuffer, const Triangle<TTriIndexElem>& inTriangle )
+ {
+ inTempBuffer << inTriangle.mIdx0
+ << " " << inTriangle.mIdx1
+ << " " << inTriangle.mIdx2;
+ }
+
+ PxU32 materialAccess( const PxTriangleMesh* inMesh, PxU32 inIndex ) { return inMesh->getTriangleMaterialIndex( inIndex ); }
+ template<typename TDataType>
+ void writeDatatype( MemoryBuffer& inTempBuffer, const TDataType& inType ) { inTempBuffer << inType; }
+
+ void PxBVH33TriangleMeshRepXSerializer::objectToFileImpl( const PxBVH33TriangleMesh* mesh, PxCollection* /*inCollection*/, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs )
+ {
+ bool hasMatIndex = mesh->getTriangleMaterialIndex(0) != 0xffff;
+ PxU32 numVertices = mesh->getNbVertices();
+ const PxVec3* vertices = mesh->getVertices();
+ writeBuffer( inWriter, inTempBuffer, 2, vertices, numVertices, "Points", writePxVec3 );
+ bool isU16 = mesh->getTriangleMeshFlags() & PxTriangleMeshFlag::e16_BIT_INDICES ? true : false;
+ PxU32 triCount = mesh->getNbTriangles();
+ const void* indices = mesh->getTriangles();
+ if ( isU16 )
+ writeBuffer( inWriter, inTempBuffer, 2, reinterpret_cast<const Triangle<PxU16>* >( indices ), triCount, "Triangles", writeTriangle<PxU16> );
+ else
+ writeBuffer( inWriter, inTempBuffer, 2, reinterpret_cast<const Triangle<PxU32>* >( indices ), triCount, "Triangles", writeTriangle<PxU32> );
+ if ( hasMatIndex )
+ writeBuffer( inWriter, inTempBuffer, 6, mesh, materialAccess, triCount, "materialIndices", writeDatatype<PxU32> );
+
+ //Cooked stream
+ PxTriangleMeshDesc meshDesc;
+ meshDesc.points.count = numVertices;
+ meshDesc.points.data = vertices;
+ meshDesc.points.stride = sizeof(PxVec3);
+ meshDesc.triangles.count = triCount;
+ meshDesc.triangles.data = indices;
+ meshDesc.triangles.stride = isU16?3*sizeof(PxU16):3*sizeof(PxU32);
+
+ if(isU16)
+ {
+ meshDesc.triangles.stride = sizeof(PxU16)*3;
+ meshDesc.flags |= PxMeshFlag::e16_BIT_INDICES;
+ }
+ else
+ {
+ meshDesc.triangles.stride = sizeof(PxU32)*3;
+ }
+
+ if(hasMatIndex)
+ {
+ PxMaterialTableIndex* materialIndices = new PxMaterialTableIndex[triCount];
+ for(PxU32 i = 0; i < triCount; i++)
+ materialIndices[i] = mesh->getTriangleMaterialIndex(i);
+
+ meshDesc.materialIndices.data = materialIndices;
+ meshDesc.materialIndices.stride = sizeof(PxMaterialTableIndex);
+
+ }
+
+ if(inArgs.cooker != NULL)
+ {
+ TMemoryPoolManager theManager(mAllocator);
+ MemoryBuffer theTempBuf( &theManager );
+ theTempBuf.clear();
+ inArgs.cooker->cookTriangleMesh( meshDesc, theTempBuf );
+
+ writeBuffer( inWriter, inTempBuffer, 16, theTempBuf.mBuffer, theTempBuf.mWriteOffset, "CookedData", writeDatatype<PxU8> );
+ }
+
+ delete []meshDesc.materialIndices.data;
+ }
+
+ PxRepXObject PxBVH33TriangleMeshRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* /*inCollection*/ )
+ {
+ //We can't do a simple inverse; we *have* to cook data to get a mesh.
+ PxTriangleMeshDesc theDesc;
+ readStridedBufferProperty<PxVec3>( inReader, "points", theDesc.points, inAllocator);
+ readStridedBufferProperty<Triangle<PxU32> >( inReader, "triangles", theDesc.triangles, inAllocator);
+ PxU32 triCount;
+ readStridedBufferProperty<PxMaterialTableIndex>( inReader, "materialIndices", theDesc.materialIndices, triCount, inAllocator);
+ PxStridedData cookedData;
+ cookedData.stride = sizeof(PxU8);
+ PxU32 dataSize;
+ readStridedBufferProperty<PxU8>( inReader, "CookedData", cookedData, dataSize, inAllocator);
+
+ TMemoryPoolManager theManager(inAllocator.getAllocator());
+ MemoryBuffer theTempBuf( &theManager );
+
+// PxTriangleMesh* theMesh = NULL;
+ PxBVH33TriangleMesh* theMesh = NULL;
+
+ if(dataSize != 0)
+ {
+ theTempBuf.write(cookedData.data, dataSize*sizeof(PxU8));
+// theMesh = inArgs.physics.createTriangleMesh( theTempBuf );
+ theMesh = static_cast<PxBVH33TriangleMesh*>(inArgs.physics.createTriangleMesh( theTempBuf ));
+ }
+
+ if(theMesh == NULL)
+ {
+ PX_ASSERT(inArgs.cooker);
+ theTempBuf.clear();
+
+ {
+ PxCookingParams params = inArgs.cooker->getParams();
+ params.midphaseDesc = PxMeshMidPhase::eBVH33;
+ inArgs.cooker->setParams(params);
+ }
+
+ inArgs.cooker->cookTriangleMesh( theDesc, theTempBuf );
+// theMesh = inArgs.physics.createTriangleMesh( theTempBuf );
+ theMesh = static_cast<PxBVH33TriangleMesh*>(inArgs.physics.createTriangleMesh( theTempBuf ));
+ }
+
+ return PxCreateRepXObject( theMesh );
+ }
+
+ void PxBVH34TriangleMeshRepXSerializer::objectToFileImpl( const PxBVH34TriangleMesh* mesh, PxCollection* /*inCollection*/, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs )
+ {
+ bool hasMatIndex = mesh->getTriangleMaterialIndex(0) != 0xffff;
+ PxU32 numVertices = mesh->getNbVertices();
+ const PxVec3* vertices = mesh->getVertices();
+ writeBuffer( inWriter, inTempBuffer, 2, vertices, numVertices, "Points", writePxVec3 );
+ bool isU16 = mesh->getTriangleMeshFlags() & PxTriangleMeshFlag::e16_BIT_INDICES ? true : false;
+ PxU32 triCount = mesh->getNbTriangles();
+ const void* indices = mesh->getTriangles();
+ if ( isU16 )
+ writeBuffer( inWriter, inTempBuffer, 2, reinterpret_cast<const Triangle<PxU16>* >( indices ), triCount, "Triangles", writeTriangle<PxU16> );
+ else
+ writeBuffer( inWriter, inTempBuffer, 2, reinterpret_cast<const Triangle<PxU32>* >( indices ), triCount, "Triangles", writeTriangle<PxU32> );
+ if ( hasMatIndex )
+ writeBuffer( inWriter, inTempBuffer, 6, mesh, materialAccess, triCount, "materialIndices", writeDatatype<PxU32> );
+
+ //Cooked stream
+ PxTriangleMeshDesc meshDesc;
+ meshDesc.points.count = numVertices;
+ meshDesc.points.data = vertices;
+ meshDesc.points.stride = sizeof(PxVec3);
+ meshDesc.triangles.count = triCount;
+ meshDesc.triangles.data = indices;
+ meshDesc.triangles.stride = isU16?3*sizeof(PxU16):3*sizeof(PxU32);
+
+ if(isU16)
+ {
+ meshDesc.triangles.stride = sizeof(PxU16)*3;
+ meshDesc.flags |= PxMeshFlag::e16_BIT_INDICES;
+ }
+ else
+ {
+ meshDesc.triangles.stride = sizeof(PxU32)*3;
+ }
+
+ if(hasMatIndex)
+ {
+ PxMaterialTableIndex* materialIndices = new PxMaterialTableIndex[triCount];
+ for(PxU32 i = 0; i < triCount; i++)
+ materialIndices[i] = mesh->getTriangleMaterialIndex(i);
+
+ meshDesc.materialIndices.data = materialIndices;
+ meshDesc.materialIndices.stride = sizeof(PxMaterialTableIndex);
+
+ }
+
+ if(inArgs.cooker != NULL)
+ {
+ TMemoryPoolManager theManager(mAllocator);
+ MemoryBuffer theTempBuf( &theManager );
+ theTempBuf.clear();
+ inArgs.cooker->cookTriangleMesh( meshDesc, theTempBuf );
+
+ writeBuffer( inWriter, inTempBuffer, 16, theTempBuf.mBuffer, theTempBuf.mWriteOffset, "CookedData", writeDatatype<PxU8> );
+ }
+
+ delete []meshDesc.materialIndices.data;
+ }
+
+ PxRepXObject PxBVH34TriangleMeshRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* /*inCollection*/ )
+ {
+ //We can't do a simple inverse; we *have* to cook data to get a mesh.
+ PxTriangleMeshDesc theDesc;
+ readStridedBufferProperty<PxVec3>( inReader, "points", theDesc.points, inAllocator);
+ readStridedBufferProperty<Triangle<PxU32> >( inReader, "triangles", theDesc.triangles, inAllocator);
+ PxU32 triCount;
+ readStridedBufferProperty<PxMaterialTableIndex>( inReader, "materialIndices", theDesc.materialIndices, triCount, inAllocator);
+ PxStridedData cookedData;
+ cookedData.stride = sizeof(PxU8);
+ PxU32 dataSize;
+ readStridedBufferProperty<PxU8>( inReader, "CookedData", cookedData, dataSize, inAllocator);
+
+ TMemoryPoolManager theManager(inAllocator.getAllocator());
+ MemoryBuffer theTempBuf( &theManager );
+
+// PxTriangleMesh* theMesh = NULL;
+ PxBVH34TriangleMesh* theMesh = NULL;
+
+ if(dataSize != 0)
+ {
+ theTempBuf.write(cookedData.data, dataSize*sizeof(PxU8));
+// theMesh = inArgs.physics.createTriangleMesh( theTempBuf );
+ theMesh = static_cast<PxBVH34TriangleMesh*>(inArgs.physics.createTriangleMesh( theTempBuf ));
+ }
+
+ if(theMesh == NULL)
+ {
+ PX_ASSERT(inArgs.cooker);
+ theTempBuf.clear();
+
+ {
+ PxCookingParams params = inArgs.cooker->getParams();
+ params.midphaseDesc = PxMeshMidPhase::eBVH34;
+ inArgs.cooker->setParams(params);
+ }
+
+ inArgs.cooker->cookTriangleMesh( theDesc, theTempBuf );
+// theMesh = inArgs.physics.createTriangleMesh( theTempBuf );
+ theMesh = static_cast<PxBVH34TriangleMesh*>(inArgs.physics.createTriangleMesh( theTempBuf ));
+ }
+
+ return PxCreateRepXObject(theMesh);
+ }
+
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxHeightField
+ //*************************************************************
+ void PxHeightFieldRepXSerializer::objectToFileImpl( const PxHeightField* inHeightField, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+ PxHeightFieldDesc theDesc;
+
+ theDesc.nbRows = inHeightField->getNbRows();
+ theDesc.nbColumns = inHeightField->getNbColumns();
+ theDesc.format = inHeightField->getFormat();
+ theDesc.samples.stride = inHeightField->getSampleStride();
+ theDesc.samples.data = NULL;
+ theDesc.thickness = inHeightField->getThickness();
+ theDesc.convexEdgeThreshold = inHeightField->getConvexEdgeThreshold();
+ theDesc.flags = inHeightField->getFlags();
+
+ PxU32 theCellCount = inHeightField->getNbRows() * inHeightField->getNbColumns();
+ PxU32 theSampleStride = sizeof( PxHeightFieldSample );
+ PxU32 theSampleBufSize = theCellCount * theSampleStride;
+ PxHeightFieldSample* theSamples = reinterpret_cast< PxHeightFieldSample*> ( inTempBuffer.mManager->allocate( theSampleBufSize ) );
+ inHeightField->saveCells( theSamples, theSampleBufSize );
+ theDesc.samples.data = theSamples;
+ writeAllProperties( &theDesc, inWriter, inTempBuffer, *inCollection );
+ writeStridedBufferProperty<PxHeightFieldSample>( inWriter, inTempBuffer, "samples", theDesc.samples, theDesc.nbRows * theDesc.nbColumns, 6, writeHeightFieldSample);
+ inTempBuffer.mManager->deallocate( reinterpret_cast<PxU8*>(theSamples) );
+ }
+
+ PxRepXObject PxHeightFieldRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ PX_ASSERT(inArgs.cooker);
+ PxHeightFieldDesc theDesc;
+ readAllProperties( inArgs, inReader, &theDesc, inAllocator, *inCollection );
+ //Now read the data...
+ PxU32 count = 0; //ignored becaues numRows and numColumns tells the story
+ readStridedBufferProperty<PxHeightFieldSample>( inReader, "samples", theDesc.samples, count, inAllocator);
+ PxHeightField* retval = inArgs.cooker->createHeightField( theDesc, inArgs.physics.getPhysicsInsertionCallback() );
+ return PxCreateRepXObject(retval);
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxConvexMesh
+ //*************************************************************
+ void PxConvexMeshRepXSerializer::objectToFileImpl( const PxConvexMesh* mesh, PxCollection* /*inCollection*/, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs )
+ {
+ writeBuffer( inWriter, inTempBuffer, 2, mesh->getVertices(), mesh->getNbVertices(), "points", writePxVec3 );
+
+ if(inArgs.cooker != NULL)
+ {
+ //Cache cooked Data
+ PxConvexMeshDesc theDesc;
+ theDesc.points.data = mesh->getVertices();
+ theDesc.points.stride = sizeof(PxVec3);
+ theDesc.points.count = mesh->getNbVertices();
+
+ theDesc.flags = PxConvexFlag::eCOMPUTE_CONVEX;
+ TMemoryPoolManager theManager(mAllocator);
+ MemoryBuffer theTempBuf( &theManager );
+ inArgs.cooker->cookConvexMesh( theDesc, theTempBuf );
+
+ writeBuffer( inWriter, inTempBuffer, 16, theTempBuf.mBuffer, theTempBuf.mWriteOffset, "CookedData", writeDatatype<PxU8> );
+ }
+
+ }
+
+ //Conversion from scene object to descriptor.
+ PxRepXObject PxConvexMeshRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* /*inCollection*/)
+ {
+ PxConvexMeshDesc theDesc;
+ readStridedBufferProperty<PxVec3>( inReader, "points", theDesc.points, inAllocator);
+ theDesc.flags = PxConvexFlag::eCOMPUTE_CONVEX;
+
+ PxStridedData cookedData;
+ cookedData.stride = sizeof(PxU8);
+ PxU32 dataSize;
+ readStridedBufferProperty<PxU8>( inReader, "CookedData", cookedData, dataSize, inAllocator);
+
+ TMemoryPoolManager theManager(inAllocator.getAllocator());
+ MemoryBuffer theTempBuf( &theManager );
+
+ PxConvexMesh* theMesh = NULL;
+
+ if(dataSize != 0)
+ {
+ theTempBuf.write(cookedData.data, dataSize*sizeof(PxU8));
+ theMesh = inArgs.physics.createConvexMesh( theTempBuf );
+ }
+
+ if(theMesh == NULL)
+ {
+ PX_ASSERT(inArgs.cooker);
+ theTempBuf.clear();
+
+ inArgs.cooker->cookConvexMesh( theDesc, theTempBuf );
+ theMesh = inArgs.physics.createConvexMesh( theTempBuf );
+ }
+
+ return PxCreateRepXObject(theMesh);
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxRigidStatic
+ //*************************************************************
+ PxRigidStatic* PxRigidStaticRepXSerializer::allocateObject( PxRepXInstantiationArgs& inArgs )
+ {
+ return inArgs.physics.createRigidStatic( PxTransform(PxIdentity) );
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxRigidDynamic
+ //*************************************************************
+ PxRigidDynamic* PxRigidDynamicRepXSerializer::allocateObject( PxRepXInstantiationArgs& inArgs )
+ {
+ return inArgs.physics.createRigidDynamic( PxTransform(PxIdentity) );
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxArticulation
+ //*************************************************************
+ void PxArticulationRepXSerializer::objectToFileImpl( const PxArticulation* inObj, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+ TNameStack nameStack( inTempBuffer.mManager->mWrapper );
+ Sn::TArticulationLinkLinkMap linkMap( inTempBuffer.mManager->mWrapper );
+ RepXVisitorWriter<PxArticulation> writer( nameStack, inWriter, inObj, inTempBuffer, *inCollection, &linkMap );
+ RepXPropertyFilter<RepXVisitorWriter<PxArticulation> > theOp( writer );
+ visitAllProperties<PxArticulation>( theOp );
+ }
+ PxArticulation* PxArticulationRepXSerializer::allocateObject( PxRepXInstantiationArgs& inArgs ) { return inArgs.physics.createArticulation(); }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxAggregate
+ //*************************************************************
+ void PxAggregateRepXSerializer::objectToFileImpl( const PxAggregate* data, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+ PxArticulationLink *link = NULL;
+ inWriter.addAndGotoChild( "Actors" );
+ for(PxU32 i = 0; i < data->getNbActors(); ++i)
+ {
+ PxActor* actor;
+
+ if(data->getActors(&actor, 1, i))
+ {
+ link = actor->is<PxArticulationLink>();
+ }
+
+ if(link && !link->getInboundJoint() )
+ {
+ writeProperty( inWriter, *inCollection, inTempBuffer, "PxArticulationRef", &link->getArticulation());
+ }
+ else if( !link )
+ {
+ PxSerialObjectId theId = 0;
+
+ theId = inCollection->getId( *actor );
+ if( theId == 0 )
+ theId = PX_PROFILE_POINTER_TO_U64( actor );
+
+ writeProperty( inWriter, *inCollection, inTempBuffer, "PxActorRef", theId );
+ }
+ }
+
+ inWriter.leaveChild( );
+
+ writeProperty( inWriter, *inCollection, inTempBuffer, "NumActors", data->getNbActors() );
+ writeProperty( inWriter, *inCollection, inTempBuffer, "MaxNbActors", data->getMaxNbActors() );
+ writeProperty( inWriter, *inCollection, inTempBuffer, "SelfCollision", data->getSelfCollision() );
+
+ writeAllProperties( data, inWriter, inTempBuffer, *inCollection );
+ }
+
+ PxRepXObject PxAggregateRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ PxU32 numActors;
+ readProperty( inReader, "NumActors", numActors );
+ PxU32 maxNbActors;
+ readProperty( inReader, "MaxNbActors", maxNbActors );
+
+ bool selfCollision;
+ bool ret = readProperty( inReader, "SelfCollision", selfCollision );
+
+ PxAggregate* theAggregate = inArgs.physics.createAggregate(maxNbActors, selfCollision);
+ ret &= readAllProperties( inArgs, inReader, theAggregate, inAllocator, *inCollection );
+
+ inReader.pushCurrentContext();
+ if ( inReader.gotoChild( "Actors" ) )
+ {
+ inReader.pushCurrentContext();
+ for( bool matSuccess = inReader.gotoFirstChild(); matSuccess;
+ matSuccess = inReader.gotoNextSibling() )
+ {
+ const char* actorType = inReader.getCurrentItemName();
+ if ( 0 == physx::shdfnd::stricmp( actorType, "PxActorRef" ) )
+ {
+ PxActor *actor = NULL;
+ ret &= readReference<PxActor>( inReader, *inCollection, actor );
+
+ if(actor)
+ {
+ PxScene *currScene = actor->getScene();
+ if(currScene)
+ {
+ currScene->removeActor(*actor);
+ }
+ theAggregate->addActor(*actor);
+ }
+ }
+ else if ( 0 == physx::shdfnd::stricmp( actorType, "PxArticulationRef" ) )
+ {
+ PxArticulation* articulation = NULL;
+ ret &= readReference<PxArticulation>( inReader, *inCollection, articulation );
+ if(articulation)
+ {
+ PxScene *currScene = articulation->getScene();
+ if(currScene)
+ {
+ currScene->removeArticulation(*articulation);
+ }
+ theAggregate->addArticulation(*articulation);
+ }
+ }
+ }
+ inReader.popCurrentContext();
+ inReader.leaveChild();
+ }
+ inReader.popCurrentContext();
+
+ return ret ? PxCreateRepXObject(theAggregate) : PxRepXObject();
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxClothFabric
+ //*************************************************************
+#if PX_USE_CLOTH_API
+
+ void writeFabricPhase( PxOutputStream& stream, const PxClothFabricPhase& phase )
+ {
+ const PxU32ToName* conv = PxEnumTraits<PxClothFabricPhaseType::Enum>().NameConversion;
+ for ( ; conv->mName != NULL; ++conv )
+ if ( conv->mValue == PxU32(phase.phaseType) )
+ stream << conv->mName;
+ stream << " " << phase.setIndex;
+ }
+
+ namespace Sn {
+ template<> struct StrToImpl<PxClothFabricPhase>
+ {
+ void strto( PxClothFabricPhase& datatype, const char*& ioData )
+ {
+ char buffer[512];
+ eatwhite( ioData );
+ nullTerminateWhite(ioData, buffer, 512 );
+
+ const PxU32ToName* conv = PxEnumTraits<PxClothFabricPhaseType::Enum>().NameConversion;
+ for ( ; conv->mName != NULL; ++conv )
+ if ( 0 == physx::shdfnd::stricmp( buffer, conv->mName ) )
+ datatype = static_cast<PxClothFabricPhaseType::Enum>( conv->mValue );
+
+ StrToImpl<PxU32>().strto( datatype.setIndex, ioData );
+ }
+ };
+ }
+
+ void PxClothFabricRepXSerializer::objectToFileImpl( const PxClothFabric* data, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+
+ PxProfileAllocatorWrapper& wrapper( inTempBuffer.mManager->getWrapper() );
+ PxU32 numParticles = data->getNbParticles();
+ PxU32 numPhases = data->getNbPhases();
+ PxU32 numRestvalues = data->getNbRestvalues();
+ PxU32 numSets = data->getNbSets();
+ PxU32 numIndices = data->getNbParticleIndices();
+ PxU32 numTethers = data->getNbTethers();
+
+ PxProfileArray<PxU8> dataBuffer( wrapper );
+ PxU32 numInts = PxMax(PxMax(numIndices, numRestvalues), numTethers);
+ dataBuffer.resize( PxU32(PxMax( PxMax( numInts * sizeof(PxU32), numTethers * sizeof(PxReal) ),
+ numPhases * sizeof(PxClothFabricPhase)) ) );
+
+ PxClothFabricPhase* phasePtr( reinterpret_cast<PxClothFabricPhase*>( dataBuffer.begin() ) );
+ PxU32* indexPtr( reinterpret_cast<PxU32*>( dataBuffer.begin() ) );
+
+ writeProperty( inWriter, *inCollection, inTempBuffer, "NbParticles", numParticles );
+
+ data->getPhases( phasePtr, numPhases );
+ writeBuffer( inWriter, inTempBuffer, 18, phasePtr, PtrAccess<PxClothFabricPhase>, numPhases, "Phases", writeFabricPhase );
+
+ PX_COMPILE_TIME_ASSERT( sizeof( PxReal ) == sizeof( PxU32 ) );
+ PxReal* realPtr = reinterpret_cast< PxReal* >( indexPtr );
+ data->getRestvalues( realPtr, numRestvalues );
+ writeBuffer( inWriter, inTempBuffer, 18, realPtr, PtrAccess<PxReal>, numRestvalues, "Restvalues", BasicDatatypeWrite<PxReal> );
+
+ data->getSets( indexPtr, numSets );
+ writeBuffer( inWriter, inTempBuffer, 18, indexPtr, PtrAccess<PxU32>, numSets, "Sets", BasicDatatypeWrite<PxU32> );
+
+ data->getParticleIndices( indexPtr, numIndices );
+ writeBuffer( inWriter, inTempBuffer, 18, indexPtr, PtrAccess<PxU32>, numIndices, "ParticleIndices", BasicDatatypeWrite<PxU32> );
+
+ data->getTetherAnchors( indexPtr, numTethers );
+ writeBuffer( inWriter, inTempBuffer, 18, indexPtr, PtrAccess<PxU32>, numTethers, "TetherAnchors", BasicDatatypeWrite<PxU32> );
+
+ data->getTetherLengths( realPtr, numTethers );
+ writeBuffer( inWriter, inTempBuffer, 18, realPtr, PtrAccess<PxReal>, numTethers, "TetherLengths", BasicDatatypeWrite<PxReal> );
+ }
+
+ //Conversion from scene object to descriptor.
+ PxRepXObject PxClothFabricRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* /*inCollection*/)
+ {
+ PxU32 strideIgnored = 0;
+
+ PxClothFabricDesc desc;
+
+ readProperty( inReader, "NbParticles", desc.nbParticles );
+
+ readStridedBufferProperty<PxClothFabricPhase>( inReader, "Phases", const_cast<PxClothFabricPhase*&>(desc.phases), strideIgnored, desc.nbPhases, inAllocator );
+
+ PxU32 numRestvalues = 0;
+ readStridedBufferProperty<PxF32>( inReader, "Restvalues", const_cast<PxF32*&>(desc.restvalues), strideIgnored, numRestvalues, inAllocator );
+
+ readStridedBufferProperty<PxU32>( inReader, "Sets", const_cast<PxU32*&>(desc.sets), strideIgnored, desc.nbSets, inAllocator );
+
+ PxU32 numIndices = 0;
+ readStridedBufferProperty<PxU32>( inReader, "ParticleIndices", const_cast<PxU32*&>(desc.indices), strideIgnored, numIndices, inAllocator );
+
+ readStridedBufferProperty<PxU32>( inReader, "TetherAnchors", const_cast<PxU32*&>(desc.tetherAnchors), strideIgnored, desc.nbTethers, inAllocator );
+ readStridedBufferProperty<PxF32>( inReader, "TetherLengths", const_cast<PxF32*&>(desc.tetherLengths), strideIgnored, desc.nbTethers, inAllocator );
+
+ PxClothFabric* newFabric = inArgs.physics.createClothFabric( desc );
+
+ PX_ASSERT( newFabric );
+ return PxCreateRepXObject(newFabric);
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxCloth
+ //*************************************************************
+ void clothParticleWriter( PxOutputStream& stream, const PxClothParticle& particle )
+ {
+ stream << particle.pos << " " << particle.invWeight;
+ }
+
+ namespace Sn {
+ template<> struct StrToImpl<PxClothParticle>
+ {
+ void strto( PxClothParticle& datatype, const char*& ioData )
+ {
+ StrToImpl<PxF32>().strto( datatype.pos[0], ioData );
+ StrToImpl<PxF32>().strto( datatype.pos[1], ioData );
+ StrToImpl<PxF32>().strto( datatype.pos[2], ioData );
+ StrToImpl<PxF32>().strto( datatype.invWeight, ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxClothCollisionSphere>
+ {
+ void strto( PxClothCollisionSphere& datatype, const char*& ioData )
+ {
+ StrToImpl<PxF32>().strto( datatype.pos[0], ioData );
+ StrToImpl<PxF32>().strto( datatype.pos[1], ioData );
+ StrToImpl<PxF32>().strto( datatype.pos[2], ioData );
+ StrToImpl<PxF32>().strto( datatype.radius, ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxClothCollisionPlane>
+ {
+ void strto( PxClothCollisionPlane& datatype, const char*& ioData )
+ {
+ StrToImpl<PxF32>().strto( datatype.normal[0], ioData );
+ StrToImpl<PxF32>().strto( datatype.normal[1], ioData );
+ StrToImpl<PxF32>().strto( datatype.normal[2], ioData );
+ StrToImpl<PxF32>().strto( datatype.distance, ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxClothCollisionTriangle>
+ {
+ void strto( PxClothCollisionTriangle& datatype, const char*& ioData )
+ {
+ StrToImpl<PxVec3>().strto( datatype.vertex0, ioData );
+ StrToImpl<PxVec3>().strto( datatype.vertex1, ioData );
+ StrToImpl<PxVec3>().strto( datatype.vertex2, ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxVec4>
+ {
+ void strto( PxVec4& datatype, const char*& ioData )
+ {
+ StrToImpl<PxF32>().strto( datatype.x, ioData );
+ StrToImpl<PxF32>().strto( datatype.y, ioData );
+ StrToImpl<PxF32>().strto( datatype.z, ioData );
+ StrToImpl<PxF32>().strto( datatype.w, ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxClothParticleMotionConstraint>
+ {
+ void strto( PxClothParticleMotionConstraint& datatype, const char*& ioData )
+ {
+ StrToImpl<PxVec3>().strto( datatype.pos, ioData );
+ StrToImpl<PxF32>().strto( datatype.radius, ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxClothParticleSeparationConstraint>
+ {
+ void strto( PxClothParticleSeparationConstraint& datatype, const char*& ioData )
+ {
+ StrToImpl<PxVec3>().strto( datatype.pos, ioData );
+ StrToImpl<PxF32>().strto( datatype.radius, ioData );
+ }
+ };
+
+ }
+
+ void clothSphereWriter( PxOutputStream& stream, const PxClothCollisionSphere& sphere )
+ {
+ stream << sphere.pos << " " << sphere.radius;
+ }
+
+ void clothPlaneWriter( PxOutputStream& stream, const PxClothCollisionPlane& plane )
+ {
+ stream << plane.normal << " " << plane.distance;
+ }
+
+ void clothTriangleWriter( PxOutputStream& stream, const PxClothCollisionTriangle& triangle )
+ {
+ stream << triangle.vertex0 << " " << triangle.vertex1 << " " << triangle.vertex2;
+ }
+
+ void PxClothRepXSerializer::objectToFileImpl( const PxCloth* data, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+ PxClothParticleData* readData( data->lockParticleData() );
+ writeBuffer( inWriter, inTempBuffer, 4, readData->particles, PtrAccess<PxClothParticle>, data->getNbParticles(), "Particles", clothParticleWriter );
+ readData->unlock();
+
+ writeReference( inWriter, *inCollection, "Fabric", data->getFabric() );
+
+ PxProfileArray<PxU8> dataBuffer( inTempBuffer.mManager->getWrapper() );
+
+ // collision data
+ const PxCloth& cloth = *data;
+ PxU32 numSpheres = cloth.getNbCollisionSpheres();
+ PxU32 numIndices = 2*cloth.getNbCollisionCapsules();
+ PxU32 numPlanes = cloth.getNbCollisionPlanes();
+ PxU32 numConvexes = cloth.getNbCollisionConvexes();
+ PxU32 numTriangles = cloth.getNbCollisionTriangles();
+
+ PxU32 sphereBytes = numSpheres * sizeof( PxClothCollisionSphere );
+ PxU32 pairBytes = numIndices * sizeof( PxU32 );
+ PxU32 planesBytes = numPlanes * sizeof(PxClothCollisionPlane);
+ PxU32 convexBytes = numConvexes * sizeof(PxU32);
+ PxU32 triangleBytes = numTriangles * sizeof(PxClothCollisionTriangle);
+
+ dataBuffer.resize( sphereBytes + pairBytes + planesBytes + convexBytes + triangleBytes);
+ PxClothCollisionSphere* spheresBuffer = reinterpret_cast<PxClothCollisionSphere*>( dataBuffer.begin() );
+ PxU32* indexBuffer = reinterpret_cast<PxU32*>(spheresBuffer + numSpheres);
+ PxClothCollisionPlane* planeBuffer = reinterpret_cast<PxClothCollisionPlane*>(indexBuffer + numIndices);
+ PxU32* convexBuffer = reinterpret_cast<PxU32*>(planeBuffer + numPlanes);
+ PxClothCollisionTriangle* trianglesBuffer = reinterpret_cast<PxClothCollisionTriangle*>(convexBuffer + numConvexes);
+
+ data->getCollisionData( spheresBuffer, indexBuffer, planeBuffer, convexBuffer, trianglesBuffer );
+ writeBuffer( inWriter, inTempBuffer, 4, spheresBuffer, PtrAccess<PxClothCollisionSphere>, numSpheres, "CollisionSpheres", clothSphereWriter );
+ writeBuffer( inWriter, inTempBuffer, 18, indexBuffer, PtrAccess<PxU32>, numIndices, "CollisionSpherePairs", BasicDatatypeWrite<PxU32> );
+ writeBuffer( inWriter, inTempBuffer, 4, planeBuffer, PtrAccess<PxClothCollisionPlane>, numPlanes, "CollisionPlanes", clothPlaneWriter );
+ writeBuffer( inWriter, inTempBuffer, 18, convexBuffer, PtrAccess<PxU32>, numConvexes, "CollisionConvexMasks", BasicDatatypeWrite<PxU32> );
+ writeBuffer( inWriter, inTempBuffer, 4, trianglesBuffer, PtrAccess<PxClothCollisionTriangle>, numTriangles, "CollisionTriangles", clothTriangleWriter );
+
+ // particle accelerations
+ PxU32 numParticleAccelerations = cloth.getNbParticleAccelerations();
+ PxU32 sizeParticleAccelerations = sizeof(PxVec4)*numParticleAccelerations;
+ if (dataBuffer.size() < sizeParticleAccelerations)
+ dataBuffer.resize(sizeof(PxClothParticle)*numParticleAccelerations);
+
+ PxVec4* particleAccelerations = reinterpret_cast<PxVec4*>(dataBuffer.begin());
+ cloth.getParticleAccelerations(particleAccelerations);
+ writeBuffer (inWriter, inTempBuffer, 4, reinterpret_cast<PxClothParticle*>(particleAccelerations), PtrAccess<PxClothParticle>, numParticleAccelerations, "ParticleAccelerations", clothParticleWriter );
+
+ //self collision indices
+ PxU32* particleCollisionIndices = reinterpret_cast<PxU32*>(dataBuffer.begin());
+ PxU32 numSelfCollisionIndices = cloth.getNbSelfCollisionIndices();
+ PxU32 sizeSelfCollisionIndices = sizeof(PxU32)*numSelfCollisionIndices;
+ if (dataBuffer.size() < sizeSelfCollisionIndices)
+ dataBuffer.resize(sizeSelfCollisionIndices);
+ data->getSelfCollisionIndices( particleCollisionIndices );
+ writeBuffer( inWriter, inTempBuffer, 18, particleCollisionIndices, PtrAccess<PxU32>, numSelfCollisionIndices, "SelfCollisionIndices", BasicDatatypeWrite<PxU32> );
+
+ // motion constraints
+ PxClothParticleMotionConstraint* motionConstraints = reinterpret_cast<PxClothParticleMotionConstraint*>(dataBuffer.begin());
+ PxU32 numMotionConstraints = cloth.getNbMotionConstraints();
+ PxU32 sizeMotionConstraints = sizeof(PxVec4)*numMotionConstraints;
+ if (dataBuffer.size() < sizeMotionConstraints)
+ dataBuffer.resize(sizeof(PxClothParticle)*numMotionConstraints);
+ data->getMotionConstraints( motionConstraints );
+ writeBuffer (inWriter, inTempBuffer, 4, reinterpret_cast<PxClothParticle*>(motionConstraints), PtrAccess<PxClothParticle>, numMotionConstraints, "MotionConstraints", clothParticleWriter );
+
+ // separation positions
+ PxU32 numSeparationConstraints= cloth.getNbSeparationConstraints();
+ PxU32 restSeparationConstraints = sizeof(PxVec4)*numSeparationConstraints;
+ if (dataBuffer.size() < restSeparationConstraints)
+ dataBuffer.resize(sizeof(PxClothParticle)*numSeparationConstraints);
+ PxClothParticleSeparationConstraint* separationConstraints = reinterpret_cast<PxClothParticleSeparationConstraint*>(dataBuffer.begin());
+ cloth.getSeparationConstraints(separationConstraints);
+ writeBuffer (inWriter, inTempBuffer, 4, reinterpret_cast<PxClothParticle*>(separationConstraints), PtrAccess<PxClothParticle>, numSeparationConstraints, "SeparationConstraints", clothParticleWriter );
+
+ // rest positions
+ PxU32 numRestPositions = cloth.getNbRestPositions();
+ PxU32 restPositionSize = sizeof(PxVec4)*numRestPositions;
+ if (dataBuffer.size() < restPositionSize)
+ dataBuffer.resize(sizeof(PxClothParticle)*numRestPositions);
+
+ PxVec4* restPositions = reinterpret_cast<PxVec4*>(dataBuffer.begin());
+ cloth.getRestPositions(restPositions);
+ writeBuffer (inWriter, inTempBuffer, 4, reinterpret_cast<PxClothParticle*>(restPositions), PtrAccess<PxClothParticle>, numRestPositions, "RestPositions", clothParticleWriter );
+
+ // virtual particles
+ PxU32 numVirtualParticles = data->getNbVirtualParticles();
+ PxU32 numWeightTableEntries = data->getNbVirtualParticleWeights();
+
+ PxU32 totalNeeded = static_cast<PxU32>( PxMax( numWeightTableEntries * sizeof( PxVec3 ), numVirtualParticles * 4 * sizeof( PxU32 ) ) );
+ if ( dataBuffer.size() < totalNeeded )
+ dataBuffer.resize( totalNeeded );
+
+ PxVec3* weightTableEntries = reinterpret_cast<PxVec3*>( dataBuffer.begin() );
+ data->getVirtualParticleWeights( weightTableEntries );
+ writeBuffer( inWriter, inTempBuffer, 6, weightTableEntries, PtrAccess<PxVec3>, numWeightTableEntries, "VirtualParticleWeights", BasicDatatypeWrite<PxVec3> );
+ PxU32* virtualParticles = reinterpret_cast<PxU32*>( dataBuffer.begin() );
+ data->getVirtualParticles( virtualParticles );
+ writeBuffer( inWriter, inTempBuffer, 18, virtualParticles, PtrAccess<PxU32>, numVirtualParticles * 4, "VirtualParticles", BasicDatatypeWrite<PxU32> );
+
+ // Now write the rest of the object data that the meta data generator got.
+ writeAllProperties( data, inWriter, inTempBuffer, *inCollection );
+ }
+
+ PxRepXObject PxClothRepXSerializer::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ PxU32 strideIgnored;
+ PxU32 numParticles;
+ PxClothParticle* particles = NULL;
+
+ PxU32 numSpheres;
+ PxClothCollisionSphere* spheres = NULL;
+ PxU32 numCapsules;
+ PxU32* capsules = NULL;
+ PxU32 numPlanes;
+ PxClothCollisionPlane* planes = NULL;
+ PxU32 numConvexMasks;
+ PxU32* convexMasks = NULL;
+ PxU32 numTriangles;
+ PxClothCollisionTriangle* triangles = NULL;
+
+ PxVec4* particleAccelerations = NULL;
+ PxU32 numParticleAccelerations = 0;
+ PxU32* selfCollisionIndices = NULL;
+ PxU32 numSelfCollisionIndices = 0;
+ PxClothParticleMotionConstraint* particleMotionConstraint = NULL;
+ PxU32 numParticleMotionConstraint = 0;
+ PxClothParticleSeparationConstraint* separationConstraints = NULL;
+ PxU32 numSeparationConstraints = 0;
+
+ PxVec4* restPositions = NULL;
+ PxU32 numRestPositions;
+ PxU32 numVirtualParticleWeights;
+ PxU32 numParticleIndices = 0;
+ PxVec3* virtualParticleWeights = NULL;
+ PxU32* virtualParticles = NULL;
+ PxClothFlags flags;
+ PxClothFabric* fabric = NULL;
+
+ readReference<PxClothFabric>( inReader, *inCollection, "Fabric", fabric );
+
+ if ( fabric == NULL )
+ return PxRepXObject();
+
+ readStridedBufferProperty<PxClothParticle>( inReader, "Particles", particles, strideIgnored, numParticles, inAllocator );
+
+ readStridedBufferProperty<PxClothCollisionSphere>( inReader, "CollisionSpheres", spheres, strideIgnored, numSpheres, inAllocator );
+ readStridedBufferProperty<PxU32>( inReader, "CollisionSpherePairs", capsules, strideIgnored, numCapsules, inAllocator );
+ readStridedBufferProperty<PxClothCollisionPlane>( inReader, "CollisionPlanes", planes, strideIgnored, numPlanes, inAllocator );
+ readStridedBufferProperty<PxU32>( inReader, "CollisionConvexMasks", convexMasks, strideIgnored, numConvexMasks, inAllocator );
+ readStridedBufferProperty<PxClothCollisionTriangle>( inReader, "CollisionTriangles", triangles, strideIgnored, numTriangles, inAllocator );
+
+ readFlagsProperty( inReader, inAllocator, "ClothFlags", PxEnumTraits<PxClothFlag::Enum>().NameConversion, flags );
+
+ readStridedBufferProperty<PxVec4>( inReader, "ParticleAccelerations", particleAccelerations, strideIgnored, numParticleAccelerations, inAllocator );
+ readStridedBufferProperty<PxU32>( inReader, "SelfCollisionIndices", selfCollisionIndices, strideIgnored, numSelfCollisionIndices, inAllocator );
+ readStridedBufferProperty<PxClothParticleMotionConstraint>( inReader, "MotionConstraints", particleMotionConstraint, strideIgnored, numParticleMotionConstraint, inAllocator );
+ readStridedBufferProperty<PxClothParticleSeparationConstraint>( inReader, "SeparationConstraints", separationConstraints, strideIgnored, numSeparationConstraints, inAllocator );
+ readStridedBufferProperty<PxVec4>( inReader, "RestPositions", restPositions, strideIgnored, numRestPositions, inAllocator );
+
+ readStridedBufferProperty<PxVec3>( inReader, "VirtualParticleWeights", virtualParticleWeights, strideIgnored, numVirtualParticleWeights, inAllocator );
+ readStridedBufferProperty<PxU32>( inReader, "VirtualParticles", virtualParticles, strideIgnored, numParticleIndices, inAllocator );
+
+ PxTransform initialPose( PxIdentity );
+ PxCloth* cloth = inArgs.physics.createCloth( initialPose, *fabric, reinterpret_cast<PxClothParticle*>( particles ), flags );
+ bool ret = readAllProperties( inArgs, inReader, cloth, inAllocator, *inCollection );
+
+ if( numSelfCollisionIndices )
+ {
+ cloth->setSelfCollisionIndices( selfCollisionIndices, numSelfCollisionIndices );
+ }
+ if( numParticleMotionConstraint )
+ {
+ cloth->setMotionConstraints( particleMotionConstraint );
+ }
+ if( numSeparationConstraints )
+ {
+ cloth->setSeparationConstraints( separationConstraints );
+ }
+ if( numParticleAccelerations )
+ {
+ cloth->setParticleAccelerations(particleAccelerations);
+ }
+
+ cloth->setCollisionSpheres(spheres, numSpheres);
+ while(numCapsules > 0)
+ {
+ PxU32 first = *capsules++, second = *capsules++;
+ cloth->addCollisionCapsule(first, second);
+ numCapsules -= 2;
+ }
+
+ cloth->setCollisionPlanes(planes, numPlanes);
+ while(numConvexMasks-- > 0)
+ {
+ cloth->addCollisionConvex(*convexMasks++);
+ }
+
+ cloth->setCollisionTriangles(triangles, numTriangles);
+
+ if (numRestPositions)
+ cloth->setRestPositions(restPositions);
+
+ PxU32 numVirtualParticles = numParticleIndices /4;
+ if ( numVirtualParticles && numVirtualParticleWeights )
+ {
+ cloth->setVirtualParticles( numVirtualParticles, reinterpret_cast<PxU32*>( virtualParticles ),
+ numVirtualParticleWeights, reinterpret_cast<PxVec3*>( virtualParticleWeights ) );
+ }
+
+ return ret ? PxCreateRepXObject(cloth) : PxRepXObject();
+ }
+#endif // PX_USE_CLOTH_API
+
+#if PX_USE_PARTICLE_SYSTEM_API
+ template<typename TParticleType>
+ inline TParticleType* createParticles( PxPhysics& physics, PxU32 maxParticles, bool perParticleRestOffset )
+ {
+ PX_UNUSED(physics);
+ PX_UNUSED(maxParticles);
+ PX_UNUSED(perParticleRestOffset);
+ return NULL;
+ }
+
+ template<>
+ inline PxParticleSystem* createParticles<PxParticleSystem>(PxPhysics& physics, PxU32 maxParticles, bool perParticleRestOffset)
+ {
+ return physics.createParticleSystem( maxParticles, perParticleRestOffset );
+ }
+
+ template<>
+ inline PxParticleFluid* createParticles<PxParticleFluid>(PxPhysics& physics, PxU32 maxParticles, bool perParticleRestOffset)
+ {
+ return physics.createParticleFluid( maxParticles, perParticleRestOffset );
+ }
+
+ //*************************************************************
+ // Actual RepXSerializer implementations for PxParticleSystem & PxParticleFluid
+ //*************************************************************
+ template<typename TParticleType>
+ void PxParticleRepXSerializer<TParticleType>::objectToFileImpl( const TParticleType* data, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+ PxParticleReadData* readData( const_cast<TParticleType*>( data )->lockParticleReadData() );
+ writeProperty( inWriter, *inCollection, inTempBuffer, "NbParticles", readData->nbValidParticles );
+ writeProperty( inWriter, *inCollection, inTempBuffer, "ValidParticleRange", readData->validParticleRange );
+ PxParticleReadDataFlags readFlags(data->getParticleReadDataFlags());
+
+ if(readData->validParticleRange > 0)
+ {
+ writeBuffer( inWriter, inTempBuffer, 8 , readData->validParticleBitmap, PtrAccess<PxU32>, ((readData->validParticleRange-1) >> 5) + 1 ,"ValidParticleBitmap", BasicDatatypeWrite<PxU32> );
+
+ writeStridedBufferProperty<PxVec3>( inWriter, inTempBuffer, "Positions", readData->positionBuffer, readData->nbValidParticles, 6, writePxVec3);
+
+ if(readFlags & PxParticleReadDataFlag::eVELOCITY_BUFFER)
+ {
+ writeStridedBufferProperty<PxVec3>( inWriter, inTempBuffer, "Velocities", readData->velocityBuffer, readData->nbValidParticles, 6, writePxVec3);
+ }
+ if(readFlags & PxParticleReadDataFlag::eREST_OFFSET_BUFFER)
+ {
+ writeStridedBufferProperty<PxF32>( inWriter, inTempBuffer, "RestOffsets", readData->restOffsetBuffer, readData->nbValidParticles, 6, BasicDatatypeWrite<PxF32>);
+ }
+ if(readFlags & PxParticleReadDataFlag::eFLAGS_BUFFER)
+ {
+ writeStridedFlagsProperty<PxParticleFlags>( inWriter, inTempBuffer, "Flags", readData->flagsBuffer, readData->nbValidParticles, 6, PxEnumTraits<PxParticleFlag::Enum>().NameConversion);
+ }
+ }
+ readData->unlock();
+
+ writeProperty( inWriter, *inCollection, inTempBuffer, "MaxParticles", data->getMaxParticles() );
+
+ PxParticleBaseFlags baseFlags(data->getParticleBaseFlags());
+ writeFlagsProperty( inWriter, inTempBuffer, "ParticleBaseFlags", baseFlags, PxEnumTraits<PxParticleBaseFlag::Enum>().NameConversion );
+
+ writeFlagsProperty( inWriter, inTempBuffer, "ParticleReadDataFlags", readFlags, PxEnumTraits<PxParticleReadDataFlag::Enum>().NameConversion );
+
+ PxVec3 normal;
+ PxReal distance;
+ data->getProjectionPlane(normal, distance);
+ PxMetaDataPlane plane(normal, distance);
+ writeProperty( inWriter, *inCollection, inTempBuffer, "ProjectionPlane", plane);
+
+ writeAllProperties( data, inWriter, inTempBuffer, *inCollection );
+ }
+
+ template<typename TParticleType>
+ PxRepXObject PxParticleRepXSerializer<TParticleType>::fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ PxU32 strideIgnored = 0;
+ PxU32 numParticles = 0;
+ readProperty( inReader, "NbParticles", numParticles );
+
+ PxU32 validParticleRange = 0;
+ readProperty( inReader, "ValidParticleRange", validParticleRange );
+
+ PxU32 numWrite;
+ PxU32* tempValidParticleBitmap = NULL;
+ readStridedBufferProperty<PxU32>( inReader, "ValidParticleBitmap", tempValidParticleBitmap, strideIgnored, numWrite, inAllocator );
+ PxU32 *validParticleBitmap = reinterpret_cast<PxU32*>( tempValidParticleBitmap );
+
+ PxVec3* tempPosBuf = NULL;
+ readStridedBufferProperty<PxVec3>( inReader, "Positions", tempPosBuf, strideIgnored, numWrite, inAllocator );
+ PxStrideIterator<const PxVec3> posBuffer(reinterpret_cast<const PxVec3*> (tempPosBuf));
+
+ PxVec3* tempVelBuf = NULL;
+ readStridedBufferProperty<PxVec3>( inReader, "Velocities", tempVelBuf, strideIgnored, numWrite, inAllocator );
+ PxStrideIterator<const PxVec3> velBuffer(reinterpret_cast<const PxVec3*> (tempVelBuf));
+
+ PxF32* tempRestBuf = NULL;
+ readStridedBufferProperty<PxF32>( inReader, "RestOffsets", tempRestBuf, strideIgnored, numWrite, inAllocator );
+ PxStrideIterator<const PxF32> restBuffer(reinterpret_cast<const PxF32*> (tempRestBuf));
+
+ PxU32* tempFlagBuf = NULL;
+ readStridedFlagsProperty<PxU32>( inReader, "Flags", tempFlagBuf, strideIgnored, numWrite, inAllocator , PxEnumTraits<PxParticleFlag::Enum>().NameConversion);
+ PxStrideIterator<const PxU32> flagBuffer(reinterpret_cast<const PxU32*> (tempFlagBuf));
+
+ Ps::Array<PxU32> validIndexBuf;
+ Ps::Array<PxVec3> validPosBuf, validVelBuf;
+ Ps::Array<PxF32> validRestBuf;
+ Ps::Array<PxU32> validFlagBuf;
+
+ bool perParticleRestOffset = !!tempRestBuf;
+ bool bVelBuff = !!tempVelBuf;
+ bool bFlagBuff = !!tempFlagBuf;
+
+ if (validParticleRange > 0)
+ {
+ for (PxU32 w = 0; w <= (validParticleRange-1) >> 5; w++)
+ {
+ for (PxU32 b = validParticleBitmap[w]; b; b &= b-1)
+ {
+ PxU32 index = (w<<5|physx::shdfnd::lowestSetBit(b));
+ validIndexBuf.pushBack(index);
+ validPosBuf.pushBack(posBuffer[index]);
+ if(bVelBuff)
+ validVelBuf.pushBack(velBuffer[index]);
+ if(perParticleRestOffset)
+ validRestBuf.pushBack(restBuffer[index]);
+ if(bFlagBuff)
+ validFlagBuf.pushBack(flagBuffer[index]);
+ }
+ }
+
+ PX_ASSERT(validIndexBuf.size() == numParticles);
+
+ PxU32 maxParticleNum;
+ bool ret = readProperty( inReader, "MaxParticles", maxParticleNum );
+ TParticleType* theParticle( createParticles<TParticleType>( inArgs.physics, maxParticleNum, perParticleRestOffset ) );
+ PX_ASSERT( theParticle );
+ ret &= readAllProperties( inArgs, inReader, theParticle, inAllocator, *inCollection );
+
+ PxParticleBaseFlags baseFlags;
+ ret &= readFlagsProperty( inReader, inAllocator, "ParticleBaseFlags", PxEnumTraits<PxParticleBaseFlag::Enum>().NameConversion, baseFlags );
+
+ PxU32 flagData = 1;
+ for(PxU32 i = 0; i < 16; i++)
+ {
+ flagData = PxU32(1 << i);
+ if( !(flagData & PxParticleBaseFlag::ePER_PARTICLE_REST_OFFSET) && (!!(PxU32(baseFlags) & flagData)) )
+ {
+ theParticle->setParticleBaseFlag(PxParticleBaseFlag::Enum(flagData), true);
+ }
+ }
+
+ PxParticleReadDataFlags readFlags;
+ ret &= readFlagsProperty( inReader, inAllocator, "ParticleReadDataFlags", PxEnumTraits<PxParticleReadDataFlag::Enum>().NameConversion, readFlags );
+ for(PxU32 i = 0; i < 16; i++)
+ {
+ flagData = PxU32(1 << i);
+ if( !!(PxU32(readFlags) & flagData) )
+ {
+ theParticle->setParticleReadDataFlag(PxParticleReadDataFlag::Enum(flagData), true);
+ }
+ }
+
+ PxParticleCreationData creationData;
+ creationData.numParticles = numParticles;
+ creationData.indexBuffer = PxStrideIterator<const PxU32>(validIndexBuf.begin());
+ creationData.positionBuffer = PxStrideIterator<const PxVec3>(validPosBuf.begin());
+ if(bVelBuff)
+ creationData.velocityBuffer = PxStrideIterator<const PxVec3>(validVelBuf.begin());
+ if(perParticleRestOffset)
+ creationData.restOffsetBuffer = PxStrideIterator<const PxF32>(validRestBuf.begin());
+ if(bFlagBuff)
+ creationData.flagBuffer = PxStrideIterator<const PxU32>(validFlagBuf.begin());
+
+ theParticle->createParticles(creationData);
+
+ return ret ? PxCreateRepXObject(theParticle) : PxRepXObject();
+ }
+ else
+ {
+ Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__,
+ "PxSerialization::createCollectionFromXml: PxParticleRepXSerializer: "
+ "Xml field \"ValidParticleRange\" is zero!");
+ return PxRepXObject();
+ }
+ }
+ // explicit instantiations
+ template struct PxParticleRepXSerializer<PxParticleSystem>;
+ template struct PxParticleRepXSerializer<PxParticleFluid>;
+#endif // #if PX_USE_PARTICLE_SYSTEM_API
+}
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.h
new file mode 100644
index 00000000..edd61210
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXCoreSerializer.h
@@ -0,0 +1,156 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef SN_REPX_CORE_SERIALIZER_H
+#define SN_REPX_CORE_SERIALIZER_H
+/** \addtogroup RepXSerializers
+ @{
+*/
+#include "foundation/PxSimpleTypes.h"
+#include "SnRepXSerializerImpl.h"
+
+#if !PX_DOXYGEN
+namespace physx
+{
+#endif
+
+ template<typename TLiveType>
+ struct RepXSerializerImpl;
+
+ class XmlReader;
+ class XmlMemoryAllocator;
+ class XmlWriter;
+ class MemoryBuffer;
+
+ struct PxMaterialRepXSerializer : RepXSerializerImpl<PxMaterial>
+ {
+ PxMaterialRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxMaterial>( inCallback ) {}
+ virtual PxMaterial* allocateObject( PxRepXInstantiationArgs& );
+ };
+
+ struct PxShapeRepXSerializer : public RepXSerializerImpl<PxShape>
+ {
+ PxShapeRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxShape>( inCallback ) {}
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxShape* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+
+ struct PxBVH33TriangleMeshRepXSerializer : public RepXSerializerImpl<PxBVH33TriangleMesh>
+ {
+ PxBVH33TriangleMeshRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxBVH33TriangleMesh>( inCallback ) {}
+ virtual void objectToFileImpl( const PxBVH33TriangleMesh*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxBVH33TriangleMesh* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+ struct PxBVH34TriangleMeshRepXSerializer : public RepXSerializerImpl<PxBVH34TriangleMesh>
+ {
+ PxBVH34TriangleMeshRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxBVH34TriangleMesh>( inCallback ) {}
+ virtual void objectToFileImpl( const PxBVH34TriangleMesh*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxBVH34TriangleMesh* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+
+ struct PxHeightFieldRepXSerializer : public RepXSerializerImpl<PxHeightField>
+ {
+ PxHeightFieldRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxHeightField>( inCallback ) {}
+ virtual void objectToFileImpl( const PxHeightField*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxHeightField* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+
+ struct PxConvexMeshRepXSerializer : public RepXSerializerImpl<PxConvexMesh>
+ {
+ PxConvexMeshRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxConvexMesh>( inCallback ) {}
+ virtual void objectToFileImpl( const PxConvexMesh*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxConvexMesh* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+
+ struct PxRigidStaticRepXSerializer : public RepXSerializerImpl<PxRigidStatic>
+ {
+ PxRigidStaticRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxRigidStatic>( inCallback ) {}
+ virtual PxRigidStatic* allocateObject( PxRepXInstantiationArgs& );
+ };
+
+ struct PxRigidDynamicRepXSerializer : public RepXSerializerImpl<PxRigidDynamic>
+ {
+ PxRigidDynamicRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxRigidDynamic>( inCallback ) {}
+ virtual PxRigidDynamic* allocateObject( PxRepXInstantiationArgs& );
+ };
+
+ struct PxArticulationRepXSerializer : public RepXSerializerImpl<PxArticulation>
+ {
+ PxArticulationRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxArticulation>( inCallback ) {}
+ virtual void objectToFileImpl( const PxArticulation*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxArticulation* allocateObject( PxRepXInstantiationArgs& );
+ };
+
+ struct PxAggregateRepXSerializer : public RepXSerializerImpl<PxAggregate>
+ {
+ PxAggregateRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxAggregate>( inCallback ) {}
+ virtual void objectToFileImpl( const PxAggregate*, PxCollection*, XmlWriter& , MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxAggregate* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+
+#if PX_USE_CLOTH_API
+ struct PxClothFabricRepXSerializer : public RepXSerializerImpl<PxClothFabric>
+ {
+ PxClothFabricRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxClothFabric>( inCallback ) {}
+ virtual void objectToFileImpl( const PxClothFabric*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxClothFabric* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+
+ struct PxClothRepXSerializer : public RepXSerializerImpl<PxCloth>
+ {
+ PxClothRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<PxCloth>( inCallback ) {}
+ virtual void objectToFileImpl( const PxCloth*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual PxCloth* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+#endif
+
+#if PX_USE_PARTICLE_SYSTEM_API
+ template<typename TParticleType>
+ struct PxParticleRepXSerializer : RepXSerializerImpl<TParticleType>
+ {
+ PxParticleRepXSerializer( PxAllocatorCallback& inCallback ) : RepXSerializerImpl<TParticleType>( inCallback ) {}
+ virtual void objectToFileImpl( const TParticleType*, PxCollection*, XmlWriter&, MemoryBuffer&, PxRepXInstantiationArgs& );
+ virtual PxRepXObject fileToObject( XmlReader&, XmlMemoryAllocator&, PxRepXInstantiationArgs&, PxCollection* );
+ virtual TParticleType* allocateObject( PxRepXInstantiationArgs& ) { return NULL; }
+ };
+#endif
+
+#if !PX_DOXYGEN
+} // namespace physx
+#endif
+
+#endif
+/** @} */
+
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXSerializerImpl.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXSerializerImpl.h
new file mode 100644
index 00000000..08fe861a
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXSerializerImpl.h
@@ -0,0 +1,90 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_REPX_SERIALIZER_IMPL_H
+#define PX_REPX_SERIALIZER_IMPL_H
+
+#include "PsUserAllocated.h"
+#include "SnXmlVisitorWriter.h"
+#include "SnXmlVisitorReader.h"
+
+namespace physx {
+ using namespace Sn;
+
+ /**
+ * The repx serializer impl takes the raw, untyped repx extension interface
+ * and implements the simpler functions plus does the reinterpret-casts required
+ * for any object to implement the serializer safely.
+ */
+ template<typename TLiveType>
+ struct RepXSerializerImpl : public PxRepXSerializer, shdfnd::UserAllocated
+ {
+ protected:
+ RepXSerializerImpl( const RepXSerializerImpl& inOther );
+ RepXSerializerImpl& operator=( const RepXSerializerImpl& inOther );
+
+ public:
+ PxAllocatorCallback& mAllocator;
+
+ RepXSerializerImpl( PxAllocatorCallback& inAllocator )
+ : mAllocator( inAllocator )
+ {
+ }
+
+ virtual const char* getTypeName() { return PxTypeInfo<TLiveType>::name(); }
+
+ virtual void objectToFile( const PxRepXObject& inLiveObject, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs )
+ {
+ const TLiveType* theObj = reinterpret_cast<const TLiveType*>( inLiveObject.serializable );
+ objectToFileImpl( theObj, inCollection, inWriter, inTempBuffer, inArgs );
+ }
+
+ virtual PxRepXObject fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ TLiveType* theObj( allocateObject( inArgs ) );
+ if ( theObj )
+ if(fileToObjectImpl( theObj, inReader, inAllocator, inArgs, inCollection ))
+ return PxCreateRepXObject(theObj);
+ return PxRepXObject();
+ }
+
+ virtual void objectToFileImpl( const TLiveType* inObj, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& /*inArgs*/)
+ {
+ writeAllProperties( inObj, inWriter, inTempBuffer, *inCollection );
+ }
+
+ virtual bool fileToObjectImpl( TLiveType* inObj, XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection )
+ {
+ return readAllProperties( inArgs, inReader, inObj, inAllocator, *inCollection );
+ }
+
+ virtual TLiveType* allocateObject( PxRepXInstantiationArgs& inArgs ) = 0;
+ };
+}
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.cpp b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.cpp
new file mode 100644
index 00000000..5eb2f40e
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.cpp
@@ -0,0 +1,444 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#include "CmPhysXCommon.h"
+#include "SnXmlImpl.h"
+#include "SnXmlReader.h"
+#include "SnXmlMemoryAllocator.h"
+#include "PsFoundation.h"
+#include "SnRepXCollection.h"
+#include "SnRepXUpgrader.h"
+
+using namespace physx::profile;
+
+namespace physx { namespace Sn {
+
+ #define DEFINE_REPX_DEFAULT_PROPERTY( name, val ) RepXDefaultEntry( name, val ),
+
+ static RepXDefaultEntry gRepX1_0Defaults[] = {
+ #include "SnRepX1_0Defaults.h"
+ };
+ static PxU32 gNumRepX1_0Default = sizeof( gRepX1_0Defaults ) / sizeof ( *gRepX1_0Defaults );
+
+ static RepXDefaultEntry gRepX3_1Defaults[] = {
+ #include "SnRepX3_1Defaults.h"
+ };
+ static PxU32 gNumRepX3_1Defaults = sizeof( gRepX3_1Defaults ) / sizeof ( *gRepX3_1Defaults );
+
+ static RepXDefaultEntry gRepX3_2Defaults[] = {
+ #include "SnRepX3_2Defaults.h"
+ };
+ static PxU32 gNumRepX3_2Defaults = sizeof( gRepX3_2Defaults ) / sizeof ( *gRepX3_2Defaults );
+
+ inline const char* nextPeriod( const char* str )
+ {
+ for( ++str; str && *str && *str != '.'; ++str ); //empty loop intentional
+ return str;
+ }
+
+ inline bool safeStrEq(const char* lhs, const char* rhs)
+ {
+ if (lhs == rhs)
+ return true;
+ //If they aren't equal, and one of them is null,
+ //then they can't be equal.
+ //This is assuming that the null char* is not equal to
+ //the empty "" char*.
+ if (!lhs || !rhs)
+ return false;
+
+ return ::strcmp(lhs, rhs) == 0;
+ }
+
+ typedef PxProfileHashMap<const char*, PxU32> TNameOffsetMap;
+
+ void setMissingPropertiesToDefault( XmlNode* topNode, XmlReaderWriter& editor, const RepXDefaultEntry* defaults, PxU32 numDefaults, TNameOffsetMap& map )
+ {
+ for ( XmlNode* child = topNode->mFirstChild; child != NULL; child = child->mNextSibling )
+ setMissingPropertiesToDefault( child, editor, defaults, numDefaults, map );
+
+ const TNameOffsetMap::Entry* entry( map.find( topNode->mName ) );
+ if ( entry )
+ {
+ XmlReaderWriter& theReader( editor );
+ theReader.setNode( *topNode );
+ char nameBuffer[512] = {0};
+ size_t nameLen = strlen( topNode->mName );
+ //For each default property entry for this node type.
+ for ( const RepXDefaultEntry* item = defaults + entry->second; strncmp( item->name, topNode->mName, nameLen ) == 0; ++item )
+ {
+ bool childAdded = false;
+ const char* nameStart = item->name + nameLen;
+ ++nameStart;
+ theReader.pushCurrentContext();
+ const char* str = nameStart;
+ while( *str )
+ {
+ const char *period = nextPeriod( str );
+ size_t len = size_t(PxMin( period - str, ptrdiff_t(1023) )); //can't be too careful these days.
+ memcpy( nameBuffer, str, len );
+ nameBuffer[len] = 0;
+ if ( theReader.gotoChild( nameBuffer ) == false )
+ {
+ childAdded = true;
+ theReader.addOrGotoChild( nameBuffer );
+ }
+ if (*period )
+ str = period + 1;
+ else
+ str = period;
+ }
+ if ( childAdded )
+ theReader.setCurrentItemValue( item->value );
+ theReader.popCurrentContext();
+ }
+ }
+ }
+
+
+ static void setMissingPropertiesToDefault( RepXCollection& collection, XmlReaderWriter& editor, const RepXDefaultEntry* defaults, PxU32 numDefaults )
+ {
+ PxProfileAllocatorWrapper wrapper( collection.getAllocator() );
+ //Release all strings at once, instead of piece by piece
+ XmlMemoryAllocatorImpl alloc( collection.getAllocator() );
+ //build a hashtable of the initial default value strings.
+ TNameOffsetMap nameOffsets( wrapper );
+ for ( PxU32 idx = 0; idx < numDefaults; ++idx )
+ {
+ const RepXDefaultEntry& item( defaults[idx] );
+ size_t nameLen = 0;
+ const char* periodPtr = nextPeriod (item.name);
+ for ( ; periodPtr && *periodPtr; ++periodPtr ) if( *periodPtr == '.' ) break;
+ if ( periodPtr == NULL || *periodPtr != '.' ) continue;
+ nameLen = size_t(periodPtr - item.name);
+ char* newMem = reinterpret_cast<char*>(alloc.allocate( PxU32(nameLen + 1) ));
+ memcpy( newMem, item.name, nameLen );
+ newMem[nameLen] = 0;
+
+ if ( nameOffsets.find( newMem ) )
+ alloc.deallocate( reinterpret_cast<PxU8*>(newMem) );
+ else
+ nameOffsets.insert( newMem, idx );
+ }
+ //Run through each collection item, and recursively find it and its children
+ //If an object's name is in the hash map, check and add any properties that don't exist.
+ //else return.
+ for ( const RepXCollectionItem* item = collection.begin(), *end = collection.end(); item != end; ++ item )
+ {
+ RepXCollectionItem theItem( *item );
+ setMissingPropertiesToDefault( theItem.descriptor, editor, defaults, numDefaults, nameOffsets );
+ }
+ }
+
+ struct RecursiveTraversal
+ {
+ RecursiveTraversal(XmlReaderWriter& editor): mEditor(editor) {}
+ void traverse()
+ {
+ mEditor.pushCurrentContext();
+ updateNode();
+ for(bool exists = mEditor.gotoFirstChild(); exists; exists = mEditor.gotoNextSibling())
+ traverse();
+ mEditor.popCurrentContext();
+ }
+ virtual void updateNode() = 0;
+ virtual ~RecursiveTraversal() {}
+ XmlReaderWriter& mEditor;
+ protected:
+ RecursiveTraversal& operator=(const RecursiveTraversal&){return *this;}
+ };
+
+
+ RepXCollection& RepXUpgrader::upgrade10CollectionTo3_1Collection(RepXCollection& src)
+ {
+ XmlReaderWriter& editor( src.createNodeEditor() );
+ setMissingPropertiesToDefault(src, editor, gRepX1_0Defaults, gNumRepX1_0Default );
+
+
+ RepXCollection* dest = &src.createCollection("3.1.1");
+
+ for ( const RepXCollectionItem* item = src.begin(), *end = src.end(); item != end; ++ item )
+ {
+ //either src or dest could do the copy operation, it doesn't matter who does it.
+ RepXCollectionItem newItem( item->liveObject, src.copyRepXNode( item->descriptor ) );
+ editor.setNode( *const_cast<XmlNode*>( newItem.descriptor ) );
+ //Some old files have this name in their system.
+ editor.renameProperty( "MassSpaceInertia", "MassSpaceInertiaTensor" );
+ editor.renameProperty( "SleepEnergyThreshold", "SleepThreshold" );
+
+ if ( strstr( newItem.liveObject.typeName, "Joint" ) || strstr( newItem.liveObject.typeName, "joint" ) )
+ {
+ //Joints changed format a bit. old joints looked like:
+ /*
+ <Actor0 >1627536</Actor0>
+ <Actor1 >1628368</Actor1>
+ <LocalPose0 >0 0 0 1 0.5 0.5 0.5</LocalPose0>
+ <LocalPose1 >0 0 0 1 0.3 0.3 0.3</LocalPose1>*/
+ //New joints look like:
+ /*
+ <Actors >
+ <actor0 >58320336</actor0>
+ <actor1 >56353568</actor1>
+ </Actors>
+ <LocalPose >
+ <eACTOR0 >0 0 0 1 0.5 0.5 0.5</eACTOR0>
+ <eACTOR1 >0 0 0 1 0.3 0.3 0.3</eACTOR1>
+ </LocalPose>
+ */
+ const char* actor0, *actor1, *lp0, *lp1;
+ editor.readAndRemoveProperty( "Actor0", actor0 );
+ editor.readAndRemoveProperty( "Actor1", actor1 );
+ editor.readAndRemoveProperty( "LocalPose0", lp0 );
+ editor.readAndRemoveProperty( "LocalPose1", lp1 );
+
+ editor.addOrGotoChild( "Actors" );
+ editor.writePropertyIfNotEmpty( "actor0", actor0 );
+ editor.writePropertyIfNotEmpty( "actor1", actor1 );
+ editor.leaveChild();
+
+ editor.addOrGotoChild( "LocalPose" );
+ editor.writePropertyIfNotEmpty( "eACTOR0", lp0 );
+ editor.writePropertyIfNotEmpty( "eACTOR1", lp1 );
+ editor.leaveChild();
+ }
+
+
+
+ //now desc owns the new node. Collections share a single allocation pool, however,
+ //which will get destroyed when all the collections referencing it are destroyed themselves.
+ //Data on nodes is shared between nodes, but the node structure itself is allocated.
+ dest->addCollectionItem( newItem );
+ }
+ editor.release();
+ src.destroy();
+ return *dest;
+ }
+
+ RepXCollection& RepXUpgrader::upgrade3_1CollectionTo3_2Collection(RepXCollection& src)
+ {
+ XmlReaderWriter& editor( src.createNodeEditor() );
+ setMissingPropertiesToDefault(src, editor, gRepX3_1Defaults, gNumRepX3_1Defaults );
+
+ RepXCollection* dest = &src.createCollection("3.2.0");
+
+ for ( const RepXCollectionItem* item = src.begin(), *end = src.end(); item != end; ++ item )
+ {
+ //either src or dest could do the copy operation, it doesn't matter who does it.
+ RepXCollectionItem newItem( item->liveObject, src.copyRepXNode( item->descriptor ) );
+ editor.setNode( *const_cast<XmlNode*>( newItem.descriptor ) );
+
+ if ( strstr( newItem.liveObject.typeName, "PxMaterial" ) )
+ {
+ editor.removeChild( "DynamicFrictionV" );
+ editor.removeChild( "StaticFrictionV" );
+ editor.removeChild( "dirOfAnisotropy" );
+ }
+ //now desc owns the new node. Collections share a single allocation pool, however,
+ //which will get destroyed when all the collections referencing it are destroyed themselves.
+ //Data on nodes is shared between nodes, but the node structure itself is allocated.
+ dest->addCollectionItem( newItem );
+ }
+ editor.release();
+ src.destroy();
+ return *dest;
+ }
+
+ RepXCollection& RepXUpgrader::upgrade3_2CollectionTo3_3Collection(RepXCollection& src)
+ {
+ XmlReaderWriter& editor( src.createNodeEditor() );
+ setMissingPropertiesToDefault(src, editor, gRepX3_2Defaults, gNumRepX3_2Defaults );
+
+ RepXCollection* dest = &src.createCollection("3.3.0");
+
+
+
+ struct RenameSpringToStiffness : public RecursiveTraversal
+ {
+ RenameSpringToStiffness(XmlReaderWriter& editor_): RecursiveTraversal(editor_) {}
+
+ void updateNode()
+ {
+ mEditor.renameProperty("Spring", "Stiffness");
+ mEditor.renameProperty("TangentialSpring", "TangentialStiffness");
+ }
+ };
+
+
+ struct UpdateArticulationSwingLimit : public RecursiveTraversal
+ {
+ UpdateArticulationSwingLimit(XmlReaderWriter& editor_): RecursiveTraversal(editor_) {}
+
+ void updateNode()
+ {
+ if(!Ps::stricmp(mEditor.getCurrentItemName(), "yLimit") && !Ps::stricmp(mEditor.getCurrentItemValue(), "0"))
+ mEditor.setCurrentItemValue("0.785398");
+
+ if(!Ps::stricmp(mEditor.getCurrentItemName(), "zLimit") && !Ps::stricmp(mEditor.getCurrentItemValue(), "0"))
+ mEditor.setCurrentItemValue("0.785398");
+
+ if(!Ps::stricmp(mEditor.getCurrentItemName(), "TwistLimit"))
+ {
+ mEditor.gotoFirstChild();
+ PxReal lower = PxReal(strtod(mEditor.getCurrentItemValue(), NULL));
+ mEditor.gotoNextSibling();
+ PxReal upper = PxReal(strtod(mEditor.getCurrentItemValue(), NULL));
+ mEditor.leaveChild();
+ if(lower>=upper)
+ {
+ mEditor.writePropertyIfNotEmpty("lower", "-0.785398");
+ mEditor.writePropertyIfNotEmpty("upper", "0.785398");
+ }
+ }
+ }
+ };
+
+
+ for ( const RepXCollectionItem* item = src.begin(), *end = src.end(); item != end; ++ item )
+ {
+ //either src or dest could do the copy operation, it doesn't matter who does it.
+ RepXCollectionItem newItem( item->liveObject, src.copyRepXNode( item->descriptor ) );
+
+
+ if ( strstr( newItem.liveObject.typeName, "PxCloth" ) || strstr( newItem.liveObject.typeName, "PxClothFabric" ) )
+ {
+ physx::shdfnd::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "Didn't suppot PxCloth upgrate from 3.2 to 3.3! ");
+ continue;
+ }
+
+ if ( strstr( newItem.liveObject.typeName, "PxParticleSystem" ) || strstr( newItem.liveObject.typeName, "PxParticleFluid" ) )
+ {
+ editor.setNode( *const_cast<XmlNode*>( newItem.descriptor ) );
+ editor.renameProperty( "PositionBuffer", "Positions" );
+ editor.renameProperty( "VelocityBuffer", "Velocities" );
+ editor.renameProperty( "RestOffsetBuffer", "RestOffsets" );
+ }
+
+ if(strstr(newItem.liveObject.typeName, "PxPrismaticJoint" )
+ || strstr(newItem.liveObject.typeName, "PxRevoluteJoint")
+ || strstr(newItem.liveObject.typeName, "PxSphericalJoint")
+ || strstr(newItem.liveObject.typeName, "PxD6Joint")
+ || strstr(newItem.liveObject.typeName, "PxArticulation"))
+ {
+ editor.setNode( *const_cast<XmlNode*>( newItem.descriptor ) );
+ RenameSpringToStiffness(editor).traverse();
+ }
+
+ if(strstr(newItem.liveObject.typeName, "PxArticulation"))
+ {
+ editor.setNode( *const_cast<XmlNode*>( newItem.descriptor ) );
+ UpdateArticulationSwingLimit(editor).traverse();
+ }
+
+
+
+ //now dest owns the new node. Collections share a single allocation pool, however,
+ //which will get destroyed when all the collections referencing it are destroyed themselves.
+ //Data on nodes is shared between nodes, but the node structure itself is allocated.
+
+ dest->addCollectionItem( newItem );
+
+ }
+ editor.release();
+ src.destroy();
+
+ return *dest;
+ }
+
+ RepXCollection& RepXUpgrader::upgrade3_3CollectionTo3_4Collection(RepXCollection& src)
+ {
+ RepXCollection* dest = &src.createCollection("3.4.0");
+
+ for ( const RepXCollectionItem* item = src.begin(), *end = src.end(); item != end; ++ item )
+ {
+ if(strstr(item->liveObject.typeName, "PxTriangleMesh"))
+ {
+ PxRepXObject newMeshRepXObj("PxBVH33TriangleMesh", item->liveObject.serializable, item->liveObject.id);
+ XmlNode* newMeshNode = src.copyRepXNode( item->descriptor );
+ newMeshNode->mName = "PxBVH33TriangleMesh";
+ RepXCollectionItem newMeshItem(newMeshRepXObj, newMeshNode);
+ dest->addCollectionItem( newMeshItem );
+ continue;
+ }
+
+ RepXCollectionItem newItem( item->liveObject, src.copyRepXNode( item->descriptor ) );
+ dest->addCollectionItem( newItem );
+ }
+ src.destroy();
+ return *dest;
+ }
+
+ RepXCollection& RepXUpgrader::upgradeCollection(RepXCollection& src)
+ {
+ const char* srcVersion = src.getVersion();
+ if( safeStrEq( srcVersion, RepXCollection::getLatestVersion() ))
+ return src;
+
+ static const char* oldVersions[] = {"1.0",
+ "3.1",
+ "3.1.1",
+ "3.2.0",
+ "3.3.0",
+ "3.3.1",
+ "3.3.2"
+ };//should be increase order
+
+ PxU32 grade = UINT16_MAX;
+ const PxU32 count = sizeof(oldVersions)/sizeof(oldVersions[0]);
+ for (PxU32 i=0; i<count; i++)
+ {
+ if( safeStrEq( srcVersion, oldVersions[i] ))
+ {
+ grade = i;
+ break;
+ }
+ }
+
+ typedef RepXCollection& (*UPGRADE_FUNCTION)(RepXCollection& src);
+
+ UPGRADE_FUNCTION procs[count] =
+ {
+ upgrade10CollectionTo3_1Collection,
+ NULL,
+ upgrade3_1CollectionTo3_2Collection,
+ upgrade3_2CollectionTo3_3Collection,
+ NULL,
+ NULL,
+ upgrade3_3CollectionTo3_4Collection,
+ };
+
+ RepXCollection* dest = &src;
+ for( PxU32 j = grade; j < count; j++ )
+ {
+ if( procs[j] )
+ dest = &(procs[j])(*dest);
+ }
+
+ return *dest;
+ }
+} }
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.h
new file mode 100644
index 00000000..9baf270c
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnRepXUpgrader.h
@@ -0,0 +1,53 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_REPX_UPGRADER_H
+#define PX_REPX_UPGRADER_H
+
+#include "foundation/PxSimpleTypes.h"
+
+namespace physx { namespace Sn {
+ class RepXCollection;
+
+ class RepXUpgrader
+ {
+ public:
+ //If a new collection is created, the source collection is destroyed.
+ //Thus you only need to release the new collection.
+ //This holds for all of the upgrade functions.
+ //So be aware, that the argument to these functions may not be valid
+ //after they are called, but the return value always will be valid.
+ static RepXCollection& upgradeCollection( RepXCollection& src );
+ static RepXCollection& upgrade10CollectionTo3_1Collection( RepXCollection& src );
+ static RepXCollection& upgrade3_1CollectionTo3_2Collection( RepXCollection& src );
+ static RepXCollection& upgrade3_2CollectionTo3_3Collection( RepXCollection& src );
+ static RepXCollection& upgrade3_3CollectionTo3_4Collection( RepXCollection& src );
+ };
+} }
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnSimpleXmlWriter.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnSimpleXmlWriter.h
new file mode 100644
index 00000000..6f63fefc
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnSimpleXmlWriter.h
@@ -0,0 +1,257 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_SIMPLEXMLWRITER_H
+#define PX_SIMPLEXMLWRITER_H
+
+#include "PsArray.h"
+#include "SnXmlMemoryPoolStreams.h"
+#include "CmPhysXCommon.h"
+
+namespace physx { namespace Sn {
+ class SimpleXmlWriter
+ {
+ public:
+
+ struct STagWatcher
+ {
+ typedef SimpleXmlWriter TXmlWriterType;
+ TXmlWriterType& mWriter;
+ STagWatcher( const STagWatcher& inOther );
+ STagWatcher& operator-( const STagWatcher& inOther );
+ STagWatcher( TXmlWriterType& inWriter, const char* inTagName )
+ : mWriter( inWriter )
+ {
+ mWriter.beginTag( inTagName );
+ }
+ ~STagWatcher() { mWriter.endTag(); }
+ protected:
+ STagWatcher& operator=(const STagWatcher&);
+ };
+
+ virtual ~SimpleXmlWriter(){}
+ virtual void beginTag( const char* inTagname ) = 0;
+ virtual void endTag() = 0;
+ virtual void addAttribute( const char* inName, const char* inValue ) = 0;
+ virtual void writeContentTag( const char* inTag, const char* inContent ) = 0;
+ virtual void addContent( const char* inContent ) = 0;
+ virtual PxU32 tabCount() = 0;
+ private:
+ SimpleXmlWriter& operator=(const SimpleXmlWriter&);
+ };
+
+ template<typename TStreamType>
+ class SimpleXmlWriterImpl : public SimpleXmlWriter
+ {
+ PxProfileAllocatorWrapper mWrapper;
+ TStreamType& mStream;
+ SimpleXmlWriterImpl( const SimpleXmlWriterImpl& inOther );
+ SimpleXmlWriterImpl& operator=( const SimpleXmlWriterImpl& inOther );
+ PxProfileArray<const char*> mTags;
+ bool mTagOpen;
+ PxU32 mInitialTagDepth;
+ public:
+
+ SimpleXmlWriterImpl( TStreamType& inStream, PxAllocatorCallback& inAllocator, PxU32 inInitialTagDepth = 0 )
+ : mWrapper( inAllocator )
+ , mStream( inStream )
+ , mTags( mWrapper )
+ , mTagOpen( false )
+ , mInitialTagDepth( inInitialTagDepth )
+ {
+ }
+ virtual ~SimpleXmlWriterImpl()
+ {
+ while( mTags.size() )
+ endTag();
+ }
+ PxU32 tabCount() { return mTags.size() + mInitialTagDepth; }
+
+ void writeTabs( PxU32 inSize )
+ {
+ inSize += mInitialTagDepth;
+ for ( PxU32 idx =0; idx < inSize; ++idx )
+ mStream << "\t";
+ }
+ void beginTag( const char* inTagname )
+ {
+ closeTag();
+ writeTabs(mTags.size());
+ mTags.pushBack( inTagname );
+ mStream << "<" << inTagname;
+ mTagOpen = true;
+ }
+ void addAttribute( const char* inName, const char* inValue )
+ {
+ PX_ASSERT( mTagOpen );
+ mStream << " " << inName << "=" << "\"" << inValue << "\"";
+ }
+ void closeTag(bool useNewline = true)
+ {
+ if ( mTagOpen )
+ {
+ mStream << " " << ">";
+ if (useNewline )
+ mStream << "\n";
+ }
+ mTagOpen = false;
+ }
+ void doEndOpenTag()
+ {
+ mStream << "</" << mTags.back() << ">" << "\n";
+ }
+ void endTag()
+ {
+ PX_ASSERT( mTags.size() );
+ if ( mTagOpen )
+ mStream << " " << "/>" << "\n";
+ else
+ {
+ writeTabs(mTags.size()-1);
+ doEndOpenTag();
+ }
+ mTagOpen = false;
+ mTags.popBack();
+ }
+
+ static bool IsNormalizableWhitespace(char c) { return c == 0x9 || c == 0xA || c == 0xD; }
+ static bool IsValidXmlCharacter(char c) { return IsNormalizableWhitespace(c) || c >= 0x20; }
+
+ void addContent( const char* inContent )
+ {
+ closeTag(false);
+ //escape xml
+ for( ; *inContent; inContent++ )
+ {
+ switch (*inContent)
+ {
+ case '<':
+ mStream << "&lt;";
+ break;
+ case '>':
+ mStream << "&gt;";
+ break;
+ case '&':
+ mStream << "&amp;";
+ break;
+ case '\'':
+ mStream << "&apos;";
+ break;
+ case '"':
+ mStream << "&quot;";
+ break;
+ default:
+ if (IsValidXmlCharacter(*inContent)) {
+ if (IsNormalizableWhitespace(*inContent))
+ {
+ char s[32];
+ Ps::snprintf(s, 32, "&#x%02X;", unsigned(*inContent));
+ mStream << s;
+ }
+ else
+ mStream << *inContent;
+ }
+ break;
+ }
+ }
+ }
+
+ void writeContentTag( const char* inTag, const char* inContent )
+ {
+ beginTag( inTag );
+ addContent( inContent );
+ doEndOpenTag();
+ mTags.popBack();
+ }
+ void insertXml( const char* inXml )
+ {
+ closeTag();
+ mStream << inXml;
+ }
+ };
+
+ struct BeginTag
+ {
+ const char* mTagName;
+ BeginTag( const char* inTagName )
+ : mTagName( inTagName ) { }
+ };
+
+ struct EndTag
+ {
+ EndTag() {}
+ };
+
+ struct Att
+ {
+ const char* mAttName;
+ const char* mAttValue;
+ Att( const char* inAttName, const char* inAttValue )
+ : mAttName( inAttName )
+ , mAttValue( inAttValue ) { }
+ };
+
+ struct Content
+ {
+ const char* mContent;
+ Content( const char* inContent )
+ : mContent( inContent ) { }
+ };
+
+
+ struct ContentTag
+ {
+ const char* mTagName;
+ const char* mContent;
+ ContentTag( const char* inTagName, const char* inContent )
+ : mTagName( inTagName )
+ , mContent( inContent ) { }
+ };
+
+ inline SimpleXmlWriter& operator<<( SimpleXmlWriter& inWriter, const BeginTag& inTag ) { inWriter.beginTag( inTag.mTagName ); return inWriter; }
+ inline SimpleXmlWriter& operator<<( SimpleXmlWriter& inWriter, const EndTag& inTag ) { PX_UNUSED(inTag); inWriter.endTag(); return inWriter; }
+ inline SimpleXmlWriter& operator<<( SimpleXmlWriter& inWriter, const Att& inTag ) { inWriter.addAttribute(inTag.mAttName, inTag.mAttValue); return inWriter; }
+ inline SimpleXmlWriter& operator<<( SimpleXmlWriter& inWriter, const Content& inTag ) { inWriter.addContent(inTag.mContent); return inWriter; }
+ inline SimpleXmlWriter& operator<<( SimpleXmlWriter& inWriter, const ContentTag& inTag ) { inWriter.writeContentTag(inTag.mTagName, inTag.mContent); return inWriter; }
+
+ inline void writeProperty( SimpleXmlWriter& inWriter, MemoryBuffer& tempBuffer, const char* inPropName )
+ {
+ PxU8 data = 0;
+ tempBuffer.write( &data, sizeof(PxU8) );
+ inWriter.writeContentTag( inPropName, reinterpret_cast<const char*>( tempBuffer.mBuffer ) );
+ tempBuffer.clear();
+ }
+
+ template<typename TDataType>
+ inline void writeProperty( SimpleXmlWriter& inWriter, MemoryBuffer& tempBuffer, const char* inPropName, TDataType inValue )
+ {
+ tempBuffer << inValue;
+ writeProperty( inWriter, tempBuffer, inPropName );
+ }
+} }
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlDeserializer.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlDeserializer.h
new file mode 100644
index 00000000..fdb29359
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlDeserializer.h
@@ -0,0 +1,188 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_DESERIALIZER_H
+#define PX_XML_DESERIALIZER_H
+
+#include "SnXmlVisitorReader.h"
+
+namespace physx { namespace Sn {
+
+ //Definitions needed internally in the Serializer headers.
+ template<typename TTriIndexElem>
+ struct Triangle
+ {
+ TTriIndexElem mIdx0;
+ TTriIndexElem mIdx1;
+ TTriIndexElem mIdx2;
+ Triangle( TTriIndexElem inIdx0 = 0, TTriIndexElem inIdx1 = 0, TTriIndexElem inIdx2 = 0)
+ : mIdx0( inIdx0 )
+ , mIdx1( inIdx1 )
+ , mIdx2( inIdx2 )
+ {
+ }
+ };
+
+ struct XmlMemoryAllocateMemoryPoolAllocator
+ {
+ XmlMemoryAllocator* mAllocator;
+ XmlMemoryAllocateMemoryPoolAllocator( XmlMemoryAllocator* inAlloc ) : mAllocator( inAlloc ) {}
+
+ PxU8* allocate( PxU32 inSize ) { return mAllocator->allocate( inSize ); }
+ void deallocate( PxU8* inMem ) { mAllocator->deallocate( inMem ); }
+ };
+
+ inline void strtoLong( Triangle<PxU32>& ioDatatype,const char*& ioData )
+ {
+ strto( ioDatatype.mIdx0, ioData );
+ strto( ioDatatype.mIdx1, ioData );
+ strto( ioDatatype.mIdx2, ioData );
+ }
+
+ inline void strtoLong( PxHeightFieldSample& ioDatatype,const char*& ioData )
+ {
+ PxU32 tempData;
+ strto( tempData, ioData );
+ if ( isBigEndian() )
+ {
+ PxU32& theItem(tempData);
+ PxU32 theDest = 0;
+ PxU8* theReadPtr( reinterpret_cast< PxU8* >( &theItem ) );
+ PxU8* theWritePtr( reinterpret_cast< PxU8* >( &theDest ) );
+ //A height field sample is a 16 bit number
+ //followed by two bytes.
+
+ //We write this out as a 32 bit integer, LE.
+ //Thus, on a big endian, we need to move the bytes
+ //around a bit.
+ //LE - 1 2 3 4
+ //BE - 4 3 2 1 - after convert from xml number
+ //Correct BE - 2 1 3 4, just like LE but with the 16 number swapped
+ theWritePtr[0] = theReadPtr[2];
+ theWritePtr[1] = theReadPtr[3];
+ theWritePtr[2] = theReadPtr[1];
+ theWritePtr[3] = theReadPtr[0];
+ theItem = theDest;
+ }
+ ioDatatype = *reinterpret_cast<PxHeightFieldSample*>( &tempData );
+ }
+
+ template<typename TDataType>
+ inline void readStridedFlagsProperty( XmlReader& ioReader, const char* inPropName, TDataType*& outData, PxU32& outStride, PxU32& outCount, XmlMemoryAllocator& inAllocator,
+ const PxU32ToName* inConversions)
+ {
+ const char* theSrcData;
+ outStride = sizeof( TDataType );
+ outData = NULL;
+ outCount = 0;
+ if ( ioReader.read( inPropName, theSrcData ) )
+ {
+ XmlMemoryAllocateMemoryPoolAllocator tempAllocator( &inAllocator );
+ MemoryBufferBase<XmlMemoryAllocateMemoryPoolAllocator> tempBuffer( &tempAllocator );
+
+ if ( theSrcData )
+ {
+ static PxU32 theCount = 0;
+ ++theCount;
+ char* theStartData = const_cast< char*>( copyStr( &tempAllocator, theSrcData ) );
+ char* aData = strtok(theStartData, " \n");
+ while( aData )
+ {
+ TDataType tempValue;
+ stringToFlagsType( aData, inAllocator, tempValue, inConversions );
+ aData = strtok(NULL," \n");
+ tempBuffer.write( &tempValue, sizeof(TDataType) );
+ }
+ outData = reinterpret_cast< TDataType* >( tempBuffer.mBuffer );
+ outCount = tempBuffer.mWriteOffset / sizeof( TDataType );
+ tempAllocator.deallocate( reinterpret_cast<PxU8*>(theStartData) );
+ }
+ tempBuffer.releaseBuffer();
+ }
+ }
+
+ template<typename TDataType>
+ inline void readStridedBufferProperty( XmlReader& ioReader, const char* inPropName, TDataType*& outData, PxU32& outStride, PxU32& outCount, XmlMemoryAllocator& inAllocator)
+ {
+ const char* theSrcData;
+ outStride = sizeof( TDataType );
+ outData = NULL;
+ outCount = 0;
+ if ( ioReader.read( inPropName, theSrcData ) )
+ {
+ XmlMemoryAllocateMemoryPoolAllocator tempAllocator( &inAllocator );
+ MemoryBufferBase<XmlMemoryAllocateMemoryPoolAllocator> tempBuffer( &tempAllocator );
+
+ if ( theSrcData )
+ {
+ static PxU32 theCount = 0;
+ ++theCount;
+ char* theStartData = const_cast< char*>( copyStr( &tempAllocator, theSrcData ) );
+ const char* theData = theStartData;
+ PxU32 theLen = strLenght( theData );
+ const char* theEndData = theData + theLen;
+ while( theData < theEndData )
+ {
+ //These buffers are whitespace delimited.
+ TDataType theType;
+ strtoLong( theType, theData );
+ tempBuffer.write( &theType, sizeof(theType) );
+ }
+ outData = reinterpret_cast< TDataType* >( tempBuffer.mBuffer );
+ outCount = tempBuffer.mWriteOffset / sizeof( TDataType );
+ tempAllocator.deallocate( reinterpret_cast<PxU8*>(theStartData) );
+ }
+ tempBuffer.releaseBuffer();
+ }
+ }
+
+ template<typename TDataType>
+ inline void readStridedBufferProperty( XmlReader& ioReader, const char* inPropName, PxStridedData& ioData, PxU32& outCount, XmlMemoryAllocator& inAllocator)
+ {
+ TDataType* tempData = NULL;
+ readStridedBufferProperty<TDataType>( ioReader, inPropName, tempData, ioData.stride, outCount, inAllocator );
+ ioData.data = tempData;
+ }
+
+ template<typename TDataType>
+ inline void readStridedBufferProperty( XmlReader& ioReader, const char* inPropName, PxTypedStridedData<TDataType>& ioData, PxU32& outCount, XmlMemoryAllocator& inAllocator)
+ {
+ TDataType* tempData = NULL;
+ readStridedBufferProperty<TDataType>( ioReader, inPropName, tempData, ioData.stride, outCount, inAllocator );
+ ioData.data = reinterpret_cast<PxMaterialTableIndex*>( tempData );
+ }
+
+ template<typename TDataType>
+ inline void readStridedBufferProperty( XmlReader& ioReader, const char* inPropName, PxBoundedData& ioData, XmlMemoryAllocator& inAllocator)
+ {
+ return readStridedBufferProperty<TDataType>( ioReader, inPropName, ioData, ioData.count, inAllocator );
+ }
+
+} }
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlImpl.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlImpl.h
new file mode 100644
index 00000000..1718cc86
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlImpl.h
@@ -0,0 +1,242 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_IMPL_H
+#define PX_XML_IMPL_H
+
+#include "SnXmlMemoryPool.h"
+#include "PsString.h"
+
+namespace physx { namespace Sn {
+
+typedef CMemoryPoolManager TMemoryPoolManager;
+
+namespace snXmlImpl {
+
+ inline PxU32 strLen( const char* inStr )
+ {
+ PxU32 len = 0;
+ if ( inStr )
+ {
+ while ( *inStr )
+ {
+ ++len;
+ ++inStr;
+ }
+ }
+ return len;
+ }
+}
+ inline const char* copyStr( PxAllocatorCallback& inAllocator, const char* inStr )
+ {
+ if ( inStr && *inStr )
+ {
+ PxU32 theLen = snXmlImpl::strLen( inStr );
+ //The memory will never be released by repx. If you want it released, you need to pass in a custom allocator
+ //that tracks all allocations and releases unreleased allocations yourself.
+ char* dest = reinterpret_cast<char* >( inAllocator.allocate( theLen + 1, "Repx::const char*", __FILE__, __LINE__ ) );
+ memcpy( dest, inStr, theLen );
+ dest[theLen] = 0;
+ return dest;
+ }
+ return "";
+ }
+
+ template<typename TManagerType>
+ inline const char* copyStr( TManagerType* inMgr, const char* inStr )
+ {
+ if ( inStr && *inStr )
+ {
+ PxU32 theLen = snXmlImpl::strLen( inStr );
+ char* dest = reinterpret_cast<char* >( inMgr->allocate( theLen + 1 ) );
+ memcpy( dest, inStr, theLen );
+ dest[theLen] = 0;
+ return dest;
+ }
+ return "";
+ }
+
+ inline void releaseStr( TMemoryPoolManager* inMgr, const char* inStr, PxU32 )
+ {
+ if ( inStr && *inStr )
+ {
+ inMgr->deallocate( reinterpret_cast< PxU8* >( const_cast<char*>( inStr ) ) );
+ }
+ }
+
+ inline void releaseStr( TMemoryPoolManager* inMgr, const char* inStr )
+ {
+ if ( inStr && *inStr )
+ {
+ PxU32 theLen = snXmlImpl::strLen( inStr );
+ releaseStr( inMgr, inStr, theLen );
+ }
+ }
+
+ struct XmlNode
+ {
+ const char* mName; //Never released until all collections are released
+ const char* mData; //Never released until all collections are released
+
+ XmlNode* mNextSibling;
+ XmlNode* mPreviousSibling;
+ XmlNode* mFirstChild;
+ XmlNode* mParent;
+ XmlNode( const XmlNode& );
+ XmlNode& operator=( const XmlNode& );
+
+ PX_INLINE void initPtrs()
+ {
+ mNextSibling = NULL;
+ mPreviousSibling = NULL;
+ mFirstChild = NULL;
+ mParent = NULL;
+ }
+
+ PX_INLINE XmlNode( const char* inName = "", const char* inData = "" )
+ : mName( inName )
+ , mData( inData )
+ { initPtrs(); }
+
+ void addChild( XmlNode* inItem )
+ {
+ inItem->mParent = this;
+ if ( mFirstChild == NULL )
+ mFirstChild = inItem;
+ else
+ {
+ XmlNode* theNode = mFirstChild;
+ //Follow the chain till the end.
+ while( theNode->mNextSibling != NULL )
+ theNode = theNode->mNextSibling;
+ theNode->mNextSibling = inItem;
+ inItem->mPreviousSibling = theNode;
+ }
+ }
+
+ PX_INLINE XmlNode* findChildByName( const char* inName )
+ {
+ for ( XmlNode* theNode = mFirstChild; theNode; theNode = theNode->mNextSibling )
+ {
+ XmlNode* theRepXNode = theNode;
+ if ( physx::shdfnd::stricmp( theRepXNode->mName, inName ) == 0 )
+ return theNode;
+ }
+ return NULL;
+ }
+
+ PX_INLINE void orphan()
+ {
+ if ( mParent )
+ {
+ if ( mParent->mFirstChild == this )
+ mParent->mFirstChild = mNextSibling;
+ }
+ if ( mPreviousSibling )
+ mPreviousSibling->mNextSibling = mNextSibling;
+ if ( mNextSibling )
+ mNextSibling->mPreviousSibling = mPreviousSibling;
+ if ( mFirstChild )
+ mFirstChild->mParent = NULL;
+ initPtrs();
+ }
+ };
+
+ inline XmlNode* allocateRepXNode( TMemoryPoolManager* inManager, const char* inName, const char* inData )
+ {
+ XmlNode* retval = inManager->allocate<XmlNode>();
+ retval->mName = copyStr( inManager, inName );
+ retval->mData = copyStr( inManager, inData );
+ return retval;
+ }
+
+ inline void release( TMemoryPoolManager* inManager, XmlNode* inNode )
+ {
+ //We *don't* release the strings associated with the node
+ //because they could be shared. Instead, we just let them 'leak'
+ //in some sense, at least until the memory manager itself is deleted.
+ //DO NOT UNCOMMENT THE LINES BELOW!!
+ //releaseStr( inManager, inNode->mName );
+ //releaseStr( inManager, inNode->mData );
+ inManager->deallocate( inNode );
+ }
+
+ static PX_INLINE void releaseNodeAndChildren( TMemoryPoolManager* inManager, XmlNode* inNode )
+ {
+ if ( inNode->mFirstChild )
+ {
+ XmlNode* childNode( inNode->mFirstChild );
+ while( childNode )
+ {
+ XmlNode* _node( childNode );
+ childNode = _node->mNextSibling;
+ releaseNodeAndChildren( inManager, _node );
+ }
+ }
+ inNode->orphan();
+ release( inManager, inNode );
+ }
+
+ static XmlNode* copyRepXNodeAndSiblings( TMemoryPoolManager* inManager, const XmlNode* inNode, XmlNode* inParent );
+
+ static XmlNode* copyRepXNode( TMemoryPoolManager* inManager, const XmlNode* inNode, XmlNode* inParent = NULL )
+ {
+ XmlNode* newNode( allocateRepXNode( inManager, NULL, NULL ) );
+ newNode->mName = inNode->mName; //Some light structural sharing
+ newNode->mData = inNode->mData; //Some light structural sharing
+ newNode->mParent = inParent;
+ if ( inNode->mFirstChild )
+ newNode->mFirstChild = copyRepXNodeAndSiblings( inManager, inNode->mFirstChild, newNode );
+ return newNode;
+ }
+
+ static XmlNode* copyRepXNodeAndSiblings( TMemoryPoolManager* inManager, const XmlNode* inNode, XmlNode* inParent )
+ {
+ XmlNode* sibling = inNode->mNextSibling;
+ if ( sibling ) sibling = copyRepXNodeAndSiblings( inManager, sibling, inParent );
+ XmlNode* newNode = copyRepXNode( inManager, inNode, inParent );
+ newNode->mNextSibling = sibling;
+ if ( sibling ) sibling->mPreviousSibling = newNode;
+ return newNode;
+ }
+
+ inline bool isBigEndian() { int i = 1; return *(reinterpret_cast<char*>(&i))==0; }
+
+
+ struct NameStackEntry
+ {
+ const char* mName;
+ bool mOpen;
+ NameStackEntry( const char* nm ) : mName( nm ), mOpen( false ) {}
+ };
+
+ typedef PxProfileArray<NameStackEntry> TNameStack;
+} }
+
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryAllocator.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryAllocator.h
new file mode 100644
index 00000000..8172a312
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryAllocator.h
@@ -0,0 +1,129 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_MEMORY_ALLOCATOR_H
+#define PX_XML_MEMORY_ALLOCATOR_H
+
+#include "foundation/PxSimpleTypes.h"
+
+namespace physx {
+
+ class XmlMemoryAllocator
+ {
+ protected:
+ virtual ~XmlMemoryAllocator(){}
+ public:
+ virtual PxU8* allocate(PxU32 inSize) = 0;
+ virtual void deallocate( PxU8* inMem ) = 0;
+ virtual PxAllocatorCallback& getAllocator() = 0;
+ template<typename TObjectType>
+ TObjectType* allocate()
+ {
+ TObjectType* retval = reinterpret_cast< TObjectType* >( allocate( sizeof( TObjectType ) ) );
+ new (retval) TObjectType();
+ return retval;
+ }
+
+ template<typename TObjectType, typename TArgType>
+ TObjectType* allocate(const TArgType &arg)
+ {
+ TObjectType* retval = reinterpret_cast< TObjectType* >( allocate( sizeof( TObjectType ) ) );
+ new (retval) TObjectType(arg);
+ return retval;
+ }
+
+ template<typename TObjectType>
+ void deallocate( TObjectType* inObject )
+ {
+ deallocate( reinterpret_cast<PxU8*>( inObject ) );
+ }
+ template<typename TObjectType>
+ inline TObjectType* batchAllocate(PxU32 inCount )
+ {
+ TObjectType* retval = reinterpret_cast<TObjectType*>( allocate( sizeof(TObjectType) * inCount ) );
+ for ( PxU32 idx = 0; idx < inCount; ++idx )
+ {
+ new (retval + idx) TObjectType();
+ }
+ return retval;
+ }
+
+ template<typename TObjectType, typename TArgType>
+ inline TObjectType* batchAllocate(PxU32 inCount, const TArgType &arg)
+ {
+ TObjectType* retval = reinterpret_cast<TObjectType*>( allocate( sizeof(TObjectType) * inCount ) );
+ for ( PxU32 idx = 0; idx < inCount; ++idx )
+ {
+ new (retval + idx) TObjectType(arg);
+ }
+ return retval;
+ }
+
+
+ //Duplicate function definition for gcc.
+ template<typename TObjectType>
+ inline TObjectType* batchAllocate(TObjectType*, PxU32 inCount )
+ {
+ TObjectType* retval = reinterpret_cast<TObjectType*>( allocate( sizeof(TObjectType) * inCount ) );
+ for ( PxU32 idx = 0; idx < inCount; ++idx )
+ {
+ new (retval + idx) TObjectType();
+ }
+ return retval;
+ }
+ };
+
+ struct XmlMemoryAllocatorImpl : public XmlMemoryAllocator
+ {
+ Sn::TMemoryPoolManager mManager;
+
+ XmlMemoryAllocatorImpl( PxAllocatorCallback& inAllocator )
+ : mManager( inAllocator )
+ {
+ }
+ XmlMemoryAllocatorImpl &operator=(const XmlMemoryAllocatorImpl &);
+ virtual PxAllocatorCallback& getAllocator()
+ {
+ return mManager.getWrapper().getAllocator();
+ }
+
+ virtual PxU8* allocate(PxU32 inSize )
+ {
+ if ( !inSize )
+ return NULL;
+
+ return mManager.allocate( inSize );
+ }
+ virtual void deallocate( PxU8* inMem )
+ {
+ if ( inMem )
+ mManager.deallocate( inMem );
+ }
+ };
+}
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPool.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPool.h
new file mode 100644
index 00000000..2c1177e3
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPool.h
@@ -0,0 +1,373 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_MEMORYPOOL_H
+#define PX_XML_MEMORYPOOL_H
+
+#include "foundation/PxAssert.h"
+#include "PsArray.h"
+#include "PxProfileAllocatorWrapper.h"
+
+namespace physx {
+
+ using namespace physx::profile;
+
+ /**
+ * Linked list used to store next node ptr.
+ */
+ struct SMemPoolNode
+ {
+ SMemPoolNode* mNextNode;
+ };
+
+ /**
+ * Template arguments are powers of two.
+ * A very fast memory pool that is not memory efficient. It contains a vector of pointers
+ * to blocks of memory along with a linked list of free sections. All sections are
+ * of the same size so allocating memory is very fast, there isn't a linear search
+ * through blocks of indeterminate size. It also means there is memory wasted
+ * when objects aren't sized to powers of two.
+ */
+ template<PxU8 TItemSize
+ , PxU8 TItemCount >
+ class CMemoryPool
+ {
+ typedef PxProfileArray<PxU8*> TPxU8PtrList;
+
+ PxProfileAllocatorWrapper& mWrapper;
+ TPxU8PtrList mAllMemory;
+ SMemPoolNode* mFirstFreeNode;
+ public:
+ CMemoryPool(PxProfileAllocatorWrapper& inWrapper)
+ : mWrapper( inWrapper )
+ , mAllMemory( inWrapper )
+ , mFirstFreeNode( NULL )
+ {}
+ ~CMemoryPool()
+ {
+ TPxU8PtrList::ConstIterator theEnd = mAllMemory.end();
+ for ( TPxU8PtrList::ConstIterator theIter = mAllMemory.begin();
+ theIter != theEnd;
+ ++theIter )
+ {
+ PxU8* thePtr = *theIter;
+ mWrapper.getAllocator().deallocate( thePtr );
+ }
+ mAllMemory.clear();
+ mFirstFreeNode = NULL;
+ }
+ //Using deallocated memory to hold the pointers to the next amount of memory.
+ PxU8* allocate()
+ {
+ if ( mFirstFreeNode )
+ {
+ PxU8* retval = reinterpret_cast<PxU8*>(mFirstFreeNode);
+ mFirstFreeNode = mFirstFreeNode->mNextNode;
+ return retval;
+ }
+ PxU32 itemSize = GetItemSize();
+ PxU32 itemCount = 1 << TItemCount;
+ //No free nodes, make some more.
+ PxU8* retval = reinterpret_cast<PxU8*>(mWrapper.getAllocator().allocate( itemCount * itemSize, "RepX fixed-size memory pool", __FILE__, __LINE__ ));
+ PxU8* dataPtr = retval + itemSize;
+ //Free extra chunks
+ for( PxU32 idx = 1; idx < itemCount; ++idx, dataPtr += itemSize )
+ deallocate( dataPtr );
+ mAllMemory.pushBack(retval);
+ return retval;
+ }
+ void deallocate( PxU8* inData )
+ {
+ SMemPoolNode* nodePtr = reinterpret_cast<SMemPoolNode*>(inData);
+ nodePtr->mNextNode = mFirstFreeNode;
+ mFirstFreeNode = nodePtr;
+ }
+ //We have to have at least a pointer's worth of memory
+ inline PxU32 GetItemSize() { return sizeof(SMemPoolNode) << TItemSize; }
+ };
+
+ typedef PxU32 TMemAllocSizeType;
+
+ struct SVariableMemPoolNode : SMemPoolNode
+ {
+ TMemAllocSizeType mSize;
+ SVariableMemPoolNode* NextNode() { return static_cast< SVariableMemPoolNode* >( mNextNode ); }
+ };
+
+ /**
+ * Manages variable sized allocations.
+ * Keeps track of freed allocations in a insertion sorted
+ * list. Allocating new memory traverses the list linearly.
+ * This object will split nodes if the node is more than
+ * twice as large as the request memory allocation.
+ */
+ class CVariableMemoryPool
+ {
+ typedef PxProfileHashMap<TMemAllocSizeType, SVariableMemPoolNode*> TFreeNodeMap;
+ typedef PxProfileArray<PxU8*> TPxU8PtrList;
+ PxProfileAllocatorWrapper& mWrapper;
+ TPxU8PtrList mAllMemory;
+ TFreeNodeMap mFreeNodeMap;
+ PxU32 mMinAllocationSize;
+
+ CVariableMemoryPool &operator=(const CVariableMemoryPool &);
+
+ public:
+ CVariableMemoryPool(PxProfileAllocatorWrapper& inWrapper, PxU32 inMinAllocationSize = 0x20 )
+ : mWrapper( inWrapper )
+ , mAllMemory( inWrapper )
+ , mFreeNodeMap( inWrapper)
+ , mMinAllocationSize( inMinAllocationSize )
+ {}
+
+ ~CVariableMemoryPool()
+ {
+ TPxU8PtrList::ConstIterator theEnd = mAllMemory.end();
+ for ( TPxU8PtrList::ConstIterator theIter = mAllMemory.begin();
+ theIter != theEnd;
+ ++theIter )
+ {
+ PxU8* thePtr = *theIter;
+ mWrapper.getAllocator().deallocate( thePtr );
+ }
+ mAllMemory.clear();
+ mFreeNodeMap.clear();
+ }
+ PxU8* MarkMem( PxU8* inMem, TMemAllocSizeType inSize )
+ {
+ PX_ASSERT( inSize >= sizeof( SVariableMemPoolNode ) );
+ SVariableMemPoolNode* theMem = reinterpret_cast<SVariableMemPoolNode*>( inMem );
+ theMem->mSize = inSize;
+ return reinterpret_cast< PxU8* >( theMem + 1 );
+ }
+ //Using deallocated memory to hold the pointers to the next amount of memory.
+ PxU8* allocate( PxU32 size )
+ {
+ //Ensure we can place the size of the memory at the start
+ //of the memory block.
+ //Kai: to reduce the size of hash map, the requested size is aligned to 128 bytes
+ PxU32 theRequestedSize = (size + sizeof(SVariableMemPoolNode) + 127) & ~127;
+
+ TFreeNodeMap::Entry* entry = const_cast<TFreeNodeMap::Entry*>( mFreeNodeMap.find( theRequestedSize ) );
+ if ( NULL != entry )
+ {
+ SVariableMemPoolNode* theNode = entry->second;
+ PX_ASSERT( NULL != theNode );
+ PX_ASSERT( theNode->mSize == theRequestedSize );
+ entry->second = theNode->NextNode();
+ if (entry->second == NULL)
+ mFreeNodeMap.erase( theRequestedSize );
+
+ return reinterpret_cast< PxU8* >( theNode + 1 );
+ }
+
+ if ( theRequestedSize < mMinAllocationSize )
+ theRequestedSize = mMinAllocationSize;
+
+ //No large enough free nodes, make some more.
+ PxU8* retval = reinterpret_cast<PxU8*>(mWrapper.getAllocator().allocate( size_t(theRequestedSize), "RepX variable sized memory pool", __FILE__, __LINE__ ));
+ //If we allocated it, we free it.
+ mAllMemory.pushBack( retval );
+ return MarkMem( retval, theRequestedSize );
+ }
+
+ //The size is stored at the beginning of the memory block.
+ void deallocate( PxU8* inData )
+ {
+ SVariableMemPoolNode* theData = reinterpret_cast< SVariableMemPoolNode* >( inData ) - 1;
+ TMemAllocSizeType theSize = theData->mSize;
+ AddFreeMem( reinterpret_cast< PxU8* >( theData ), theSize );
+ }
+
+ void CheckFreeListInvariant( SVariableMemPoolNode* inNode )
+ {
+ if ( inNode && inNode->mNextNode )
+ {
+ PX_ASSERT( inNode->mSize <= inNode->NextNode()->mSize );
+ }
+ }
+
+ void AddFreeMem( PxU8* inMemory, TMemAllocSizeType inSize )
+ {
+ PX_ASSERT( inSize >= sizeof( SVariableMemPoolNode ) );
+ SVariableMemPoolNode* theNewNode = reinterpret_cast< SVariableMemPoolNode* >( inMemory );
+ theNewNode->mNextNode = NULL;
+ theNewNode->mSize = inSize;
+ TFreeNodeMap::Entry* entry = const_cast<TFreeNodeMap::Entry*>( mFreeNodeMap.find( inSize ) );
+ if (NULL != entry)
+ {
+ theNewNode->mNextNode = entry->second;
+ entry->second = theNewNode;
+ }
+ else
+ {
+ mFreeNodeMap.insert( inSize, theNewNode );
+ }
+ }
+ };
+
+ /**
+ * The manager keeps a list of memory pools for different sizes of allocations.
+ * Anything too large simply gets allocated using the new operator.
+ * This doesn't mark the memory with the size of the allocated memory thus
+ * allowing much more efficient allocation of small items. For large enough
+ * allocations, it does mark the size.
+ *
+ * When using as a general memory manager, you need to wrap this class with
+ * something that actually does mark the returned allocation with the size
+ * of the allocation.
+ */
+ class CMemoryPoolManager
+ {
+ CMemoryPoolManager &operator=(const CMemoryPoolManager &);
+
+ public:
+ PxProfileAllocatorWrapper mWrapper;
+
+ //CMemoryPool<0,8> m0ItemPool;
+ //CMemoryPool<1,8> m1ItemPool;
+ //CMemoryPool<2,8> m2ItemPool;
+ //CMemoryPool<3,8> m3ItemPool;
+ //CMemoryPool<4,8> m4ItemPool;
+ //CMemoryPool<5,8> m5ItemPool;
+ //CMemoryPool<6,8> m6ItemPool;
+ //CMemoryPool<7,8> m7ItemPool;
+ //CMemoryPool<8,8> m8ItemPool;
+ CVariableMemoryPool mVariablePool;
+ CMemoryPoolManager( PxAllocatorCallback& inAllocator )
+ : mWrapper( inAllocator )
+ //, m0ItemPool( mWrapper )
+ //, m1ItemPool( mWrapper )
+ //, m2ItemPool( mWrapper )
+ //, m3ItemPool( mWrapper )
+ //, m4ItemPool( mWrapper )
+ //, m5ItemPool( mWrapper )
+ //, m6ItemPool( mWrapper )
+ //, m7ItemPool( mWrapper )
+ //, m8ItemPool( mWrapper )
+ , mVariablePool( mWrapper )
+ {
+ }
+ PxProfileAllocatorWrapper& getWrapper() { return mWrapper; }
+ inline PxU8* allocate( PxU32 inSize )
+ {
+ /*
+ if ( inSize <= m0ItemPool.GetItemSize() )
+ return m0ItemPool.allocate();
+ if ( inSize <= m1ItemPool.GetItemSize() )
+ return m1ItemPool.allocate();
+ if ( inSize <= m2ItemPool.GetItemSize() )
+ return m2ItemPool.allocate();
+ if ( inSize <= m3ItemPool.GetItemSize() )
+ return m3ItemPool.allocate();
+ if ( inSize <= m4ItemPool.GetItemSize() )
+ return m4ItemPool.allocate();
+ if ( inSize <= m5ItemPool.GetItemSize() )
+ return m5ItemPool.allocate();
+ if ( inSize <= m6ItemPool.GetItemSize() )
+ return m6ItemPool.allocate();
+ if ( inSize <= m7ItemPool.GetItemSize() )
+ return m7ItemPool.allocate();
+ if ( inSize <= m8ItemPool.GetItemSize() )
+ return m8ItemPool.allocate();
+ */
+ return mVariablePool.allocate( inSize );
+ }
+ inline void deallocate( PxU8* inMemory )
+ {
+ if ( inMemory == NULL )
+ return;
+ /*
+ if ( inSize <= m0ItemPool.GetItemSize() )
+ m0ItemPool.deallocate(inMemory);
+ else if ( inSize <= m1ItemPool.GetItemSize() )
+ m1ItemPool.deallocate(inMemory);
+ else if ( inSize <= m2ItemPool.GetItemSize() )
+ m2ItemPool.deallocate(inMemory);
+ else if ( inSize <= m3ItemPool.GetItemSize() )
+ m3ItemPool.deallocate(inMemory);
+ else if ( inSize <= m4ItemPool.GetItemSize() )
+ m4ItemPool.deallocate(inMemory);
+ else if ( inSize <= m5ItemPool.GetItemSize() )
+ m5ItemPool.deallocate(inMemory);
+ else if ( inSize <= m6ItemPool.GetItemSize() )
+ m6ItemPool.deallocate(inMemory);
+ else if ( inSize <= m7ItemPool.GetItemSize() )
+ m7ItemPool.deallocate(inMemory);
+ else if ( inSize <= m8ItemPool.GetItemSize() )
+ m8ItemPool.deallocate(inMemory);
+ else
+ */
+ mVariablePool.deallocate(inMemory);
+ }
+ /**
+ * allocate an object. Calls constructor on the new memory.
+ */
+ template<typename TObjectType>
+ inline TObjectType* allocate()
+ {
+ TObjectType* retval = reinterpret_cast<TObjectType*>( allocate( sizeof(TObjectType) ) );
+ new (retval)TObjectType();
+ return retval;
+ }
+
+ /**
+ * deallocate an object calling the destructor on the object.
+ * This *must* be the concrete type, it cannot be a generic type.
+ */
+ template<typename TObjectType>
+ inline void deallocate( TObjectType* inObject )
+ {
+ inObject->~TObjectType();
+ deallocate( reinterpret_cast<PxU8*>(inObject) );
+ }
+
+ /**
+ * allocate an object. Calls constructor on the new memory.
+ */
+ template<typename TObjectType>
+ inline TObjectType* BatchAllocate(PxU32 inCount )
+ {
+ TObjectType* retval = reinterpret_cast<TObjectType*>( allocate( sizeof(TObjectType) * inCount ) );
+ return retval;
+ }
+
+ /**
+ * deallocate an object calling the destructor on the object.
+ * This *must* be the concrete type, it cannot be a generic type.
+ */
+ template<typename TObjectType>
+ inline void BatchDeallocate( TObjectType* inObject, PxU32 inCount )
+ {
+ PX_UNUSED(inCount);
+ deallocate( reinterpret_cast<PxU8*>(inObject) );
+ }
+ };
+}
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPoolStreams.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPoolStreams.h
new file mode 100644
index 00000000..375d1e2d
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlMemoryPoolStreams.h
@@ -0,0 +1,173 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_MEMORY_POOL_STREAMS_H
+#define PX_XML_MEMORY_POOL_STREAMS_H
+
+#include "foundation/PxTransform.h"
+#include "foundation/PxIO.h"
+#include "SnXmlMemoryPool.h"
+#include "CmPhysXCommon.h"
+
+namespace physx {
+
+ template<typename TDataType>
+ struct XmlDefaultValue
+ {
+ bool force_compile_error;
+ };
+
+
+#define XML_DEFINE_DEFAULT_VALUE(type, defVal ) \
+ template<> \
+ struct XmlDefaultValue<type> \
+ { \
+ type getDefaultValue() { return type(defVal); } \
+ };
+
+ XML_DEFINE_DEFAULT_VALUE(PxU8, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxI8, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxU16, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxI16, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxU32, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxI32, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxU64, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxI64, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxF32, 0)
+ XML_DEFINE_DEFAULT_VALUE(PxF64, 0)
+
+#undef XML_DEFINE_DEFAULT_VALUE
+
+ template<>
+ struct XmlDefaultValue<PxVec3>
+ {
+ PxVec3 getDefaultValue() { return PxVec3( 0,0,0 ); }
+ };
+
+ template<>
+ struct XmlDefaultValue<PxTransform>
+ {
+ PxTransform getDefaultValue() { return PxTransform(PxIdentity); }
+ };
+
+ template<>
+ struct XmlDefaultValue<PxQuat>
+ {
+ PxQuat getDefaultValue() { return PxQuat(PxIdentity); }
+ };
+
+/**
+ * Mapping of PxOutputStream to a memory pool manager.
+ * Allows write-then-read semantics of a set of
+ * data. Can safely write up to 4GB of data; then you
+ * will silently fail...
+ */
+
+template<typename TAllocatorType>
+struct MemoryBufferBase : public PxOutputStream, public PxInputStream
+{
+ TAllocatorType* mManager;
+ mutable PxU32 mWriteOffset;
+ mutable PxU32 mReadOffset;
+ PxU8* mBuffer;
+ PxU32 mCapacity;
+
+
+ MemoryBufferBase( TAllocatorType* inManager )
+ : mManager( inManager )
+ , mWriteOffset( 0 )
+ , mReadOffset( 0 )
+ , mBuffer( NULL )
+ , mCapacity( 0 )
+ {
+ }
+ virtual ~MemoryBufferBase()
+ {
+ mManager->deallocate( mBuffer );
+ }
+ PxU8* releaseBuffer()
+ {
+ clear();
+ mCapacity = 0;
+ PxU8* retval(mBuffer);
+ mBuffer = NULL;
+ return retval;
+ }
+ void clear()
+ {
+ mWriteOffset = mReadOffset = 0;
+ }
+
+ virtual PxU32 read(void* dest, PxU32 count)
+ {
+ bool fits = ( mReadOffset + count ) <= mWriteOffset;
+ PX_ASSERT( fits );
+ if ( fits )
+ {
+ memcpy( dest, mBuffer + mReadOffset, count );
+ mReadOffset += count;
+ return count;
+ }
+ return 0;
+ }
+
+ inline void checkCapacity( PxU32 inNewCapacity )
+ {
+ if ( mCapacity < inNewCapacity )
+ {
+ PxU32 newCapacity = 32;
+ while( newCapacity < inNewCapacity )
+ newCapacity = newCapacity << 1;
+
+ PxU8* newData( mManager->allocate( newCapacity ) );
+ if ( mWriteOffset )
+ memcpy( newData, mBuffer, mWriteOffset );
+ mManager->deallocate( mBuffer );
+ mBuffer = newData;
+ mCapacity = newCapacity;
+ }
+ }
+
+ virtual PxU32 write(const void* src, PxU32 count)
+ {
+ checkCapacity( mWriteOffset + count );
+ memcpy( mBuffer + mWriteOffset, src, count );
+ mWriteOffset += count;
+ return count;
+ }
+};
+
+class MemoryBuffer : public MemoryBufferBase<CMemoryPoolManager >
+{
+public:
+ MemoryBuffer( CMemoryPoolManager* inManager ) : MemoryBufferBase<CMemoryPoolManager >( inManager ) {}
+};
+
+}
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlReader.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlReader.h
new file mode 100644
index 00000000..88053d96
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlReader.h
@@ -0,0 +1,130 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_READER_H
+#define PX_XML_READER_H
+
+#include "foundation/PxSimpleTypes.h"
+#include "extensions/PxRepXSimpleType.h"
+
+namespace physx {
+ namespace Sn { struct XmlNode; }
+
+ /**
+ * Reader used to read data out of the repx format.
+ */
+ class XmlReader
+ {
+ protected:
+ virtual ~XmlReader(){}
+ public:
+ /** Read a key-value pair out of the database */
+ virtual bool read( const char* inName, const char*& outData ) = 0;
+ /** Read an object id out of the database */
+ virtual bool read( const char* inName, PxSerialObjectId& outId ) = 0;
+ /** Goto a child element by name. That child becomes this reader's context */
+ virtual bool gotoChild( const char* inName ) = 0;
+ /** Goto the first child regardless of name */
+ virtual bool gotoFirstChild() = 0;
+ /** Goto the next sibling regardless of name */
+ virtual bool gotoNextSibling() = 0;
+ /** Count all children of the current object */
+ virtual PxU32 countChildren() = 0;
+ /** Get the name of the current item */
+ virtual const char* getCurrentItemName() = 0;
+ /** Get the value of the current item */
+ virtual const char* getCurrentItemValue() = 0;
+ /** Leave the current child */
+ virtual bool leaveChild() = 0;
+ /** Get reader for the parental object */
+ virtual XmlReader* getParentReader() = 0;
+
+ /**
+ * Ensures we don't leave the reader in an odd state
+ * due to not leaving a given child
+ */
+ virtual void pushCurrentContext() = 0;
+ /** Pop the current context back to where it during push*/
+ virtual void popCurrentContext() = 0;
+ };
+
+ //Used when upgrading a repx collection
+ class XmlReaderWriter : public XmlReader
+ {
+ public:
+ //Clears the stack of nodes (push/pop current node reset)
+ //and sets the current node to inNode.
+ virtual void setNode( Sn::XmlNode& node ) = 0;
+ //If the child exists, add it.
+ //the either way goto that child.
+ virtual void addOrGotoChild( const char* name ) = 0;
+ //Value is copied into the collection, inValue has no further references
+ //to it.
+ virtual void setCurrentItemValue( const char* value ) = 0;
+ //Removes the child but does not release the char* name or char* data ptrs.
+ //Those pointers are never released and are shared among collections.
+ //Thus copying nodes is cheap and safe.
+ virtual bool removeChild( const char* name ) = 0;
+ virtual void release() = 0;
+
+ bool renameProperty( const char* oldName, const char* newName )
+ {
+ if ( gotoChild( oldName ) )
+ {
+ const char* value = getCurrentItemValue();
+ leaveChild();
+ removeChild( oldName );
+ addOrGotoChild( newName );
+ setCurrentItemValue( value );
+ leaveChild();
+ return true;
+ }
+ return false;
+ }
+ bool readAndRemoveProperty( const char* name, const char*& outValue )
+ {
+ bool retval = read( name, outValue );
+ if ( retval ) removeChild( name );
+ return retval;
+ }
+
+ bool writePropertyIfNotEmpty( const char* name, const char* value )
+ {
+ if ( value && *value )
+ {
+ addOrGotoChild( name );
+ setCurrentItemValue( value );
+ leaveChild();
+ return true;
+ }
+ return false;
+ }
+ };
+
+}
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerialization.cpp b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerialization.cpp
new file mode 100644
index 00000000..af86eafd
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerialization.cpp
@@ -0,0 +1,834 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#include "SnXmlImpl.h"
+#include "PsHash.h"
+#include "PsHashMap.h"
+#include "SnSimpleXmlWriter.h"
+#include "PsSort.h"
+#include "PsFastXml.h"
+#include "PsString.h"
+#include "SnXmlMemoryPool.h"
+#include "PxExtensionMetaDataObjects.h"
+#include "SnXmlVisitorWriter.h"
+#include "SnXmlVisitorReader.h"
+#include "SnXmlMemoryAllocator.h"
+#include "SnXmlStringToType.h"
+#include "PsString.h"
+#include "SnRepXCollection.h"
+#include "SnRepXUpgrader.h"
+#include "../SnSerializationRegistry.h"
+#include "PsFoundation.h"
+#include "CmCollection.h"
+
+using namespace physx;
+using namespace Sn;
+
+using namespace physx::profile; //for the foundation wrapper system.
+
+namespace physx { namespace Sn {
+
+ class XmlNodeWriter : public SimpleXmlWriter
+ {
+ XmlMemoryAllocatorImpl& mParseAllocator;
+ XmlNode* mCurrentNode;
+ XmlNode* mTopNode;
+ PxU32 mTabCount;
+
+ public:
+ XmlNodeWriter( XmlMemoryAllocatorImpl& inAllocator, PxU32 inTabCount = 0 )
+ : mParseAllocator( inAllocator )
+ , mCurrentNode( NULL )
+ , mTopNode( NULL )
+ , mTabCount( inTabCount )
+ {}
+ XmlNodeWriter& operator=(const XmlNodeWriter&);
+ virtual ~XmlNodeWriter(){}
+ void onNewNode( XmlNode* newNode )
+ {
+ if ( mCurrentNode != NULL )
+ mCurrentNode->addChild( newNode );
+ if ( mTopNode == NULL )
+ mTopNode = newNode;
+ mCurrentNode = newNode;
+ ++mTabCount;
+ }
+
+ XmlNode* getTopNode() const { return mTopNode; }
+
+ virtual void beginTag( const char* inTagname )
+ {
+ onNewNode( allocateRepXNode( &mParseAllocator.mManager, inTagname, NULL ) );
+ }
+ virtual void endTag()
+ {
+ if ( mCurrentNode )
+ mCurrentNode = mCurrentNode->mParent;
+ if ( mTabCount )
+ --mTabCount;
+ }
+ virtual void addAttribute( const char*, const char* )
+ {
+ PX_ASSERT( false );
+ }
+ virtual void writeContentTag( const char* inTag, const char* inContent )
+ {
+ onNewNode( allocateRepXNode( &mParseAllocator.mManager, inTag, inContent ) );
+ endTag();
+ }
+ virtual void addContent( const char* inContent )
+ {
+ if ( mCurrentNode->mData )
+ releaseStr( &mParseAllocator.mManager, mCurrentNode->mData );
+ mCurrentNode->mData = copyStr( &mParseAllocator.mManager, inContent );
+ }
+ virtual PxU32 tabCount() { return mTabCount; }
+ };
+
+ struct XmlWriterImpl : public XmlWriter
+ {
+ PxU32 mTagDepth;
+ SimpleXmlWriter* mWriter;
+ MemoryBuffer* mMemBuffer;
+
+ XmlWriterImpl( SimpleXmlWriter* inWriter, MemoryBuffer* inMemBuffer )
+ : mTagDepth( 0 )
+ , mWriter( inWriter )
+ , mMemBuffer( inMemBuffer )
+ {
+ }
+ ~XmlWriterImpl()
+ {
+ while( mTagDepth )
+ {
+ --mTagDepth;
+ mWriter->endTag();
+ }
+ }
+ virtual void write( const char* inName, const char* inData )
+ {
+ mWriter->writeContentTag( inName, inData );
+ }
+ virtual void write( const char* inName, const PxRepXObject& inLiveObject )
+ {
+ (*mMemBuffer) << inLiveObject.id;
+ writeProperty( *mWriter, *mMemBuffer, inName );
+ }
+ virtual void addAndGotoChild( const char* inName )
+ {
+ mWriter->beginTag( inName );
+ mTagDepth++;
+ }
+ virtual void leaveChild()
+ {
+ if ( mTagDepth )
+ {
+ mWriter->endTag();
+ --mTagDepth;
+ }
+ }
+ };
+
+ struct XmlParseArgs
+ {
+ XmlMemoryAllocatorImpl* mAllocator;
+ PxProfileArray<RepXCollectionItem>* mCollection;
+
+ XmlParseArgs( XmlMemoryAllocatorImpl* inAllocator
+ , PxProfileArray<RepXCollectionItem>* inCollection)
+ : mAllocator( inAllocator )
+ , mCollection( inCollection )
+ {
+ }
+ };
+
+ struct XmlNodeReader : public XmlReaderWriter
+ {
+ PxProfileAllocatorWrapper mWrapper;
+ CMemoryPoolManager& mManager;
+ XmlNode* mCurrentNode;
+ XmlNode* mTopNode;
+ PxProfileArray<XmlNode*> mContext;
+ XmlNodeReader( XmlNode* inCurrentNode, PxAllocatorCallback& inAllocator, CMemoryPoolManager& nodePoolManager )
+ : mWrapper( inAllocator )
+ , mManager( nodePoolManager )
+ , mCurrentNode( inCurrentNode )
+ , mTopNode( inCurrentNode )
+ , mContext( mWrapper )
+ {
+ }
+
+ //Does this node exist as data in the format.
+ virtual bool read( const char* inName, const char*& outData )
+ {
+ XmlNode* theChild( mCurrentNode->findChildByName( inName ) );
+ if ( theChild )
+ {
+ outData = theChild->mData;
+ return outData && *outData;
+ }
+ return false;
+ }
+
+ virtual bool read( const char* inName, PxSerialObjectId& outId )
+ {
+ XmlNode* theChild( mCurrentNode->findChildByName( inName ) );
+ if ( theChild )
+ {
+ const char* theValue( theChild->mData );
+ strto( outId, theValue );
+ return true;
+ }
+ return false;
+ }
+
+ virtual bool gotoChild( const char* inName )
+ {
+ XmlNode* theChild( mCurrentNode->findChildByName( inName ) );
+ if ( theChild )
+ {
+ mCurrentNode =theChild;
+ return true;
+ }
+ return false;
+ }
+ virtual bool gotoFirstChild()
+ {
+ if ( mCurrentNode->mFirstChild )
+ {
+ mCurrentNode = mCurrentNode->mFirstChild;
+ return true;
+ }
+ return false;
+ }
+ virtual bool gotoNextSibling()
+ {
+ if ( mCurrentNode->mNextSibling )
+ {
+ mCurrentNode = mCurrentNode->mNextSibling;
+ return true;
+ }
+ return false;
+ }
+ virtual PxU32 countChildren()
+ {
+ PxU32 retval= 0;
+ for ( XmlNode* theChild = mCurrentNode->mFirstChild; theChild != NULL; theChild = theChild->mNextSibling )
+ ++retval;
+ return retval;
+ }
+ virtual const char* getCurrentItemName()
+ {
+ return mCurrentNode->mName;
+ }
+ virtual const char* getCurrentItemValue()
+ {
+ return mCurrentNode->mData;
+ }
+
+ virtual bool leaveChild()
+ {
+ if ( mCurrentNode != mTopNode && mCurrentNode->mParent )
+ {
+ mCurrentNode = mCurrentNode->mParent;
+ return true;
+ }
+ return false;
+ }
+
+ virtual void pushCurrentContext()
+ {
+ mContext.pushBack( mCurrentNode );
+ }
+ virtual void popCurrentContext()
+ {
+ if ( mContext.size() )
+ {
+ mCurrentNode = mContext.back();
+ mContext.popBack();
+ }
+ }
+
+ virtual void setNode( XmlNode& inNode )
+ {
+ mContext.clear();
+ mCurrentNode = &inNode;
+ mTopNode = mCurrentNode;
+ }
+
+ virtual XmlReader* getParentReader()
+ {
+ XmlReader* retval = PX_PLACEMENT_NEW((mWrapper.getAllocator().allocate(sizeof(XmlNodeReader), "createNodeEditor", __FILE__, __LINE__ )), XmlNodeReader)
+ ( mTopNode, mWrapper.getAllocator(), mManager );
+ return retval;
+ }
+
+ virtual void addOrGotoChild( const char* inName )
+ {
+ if ( gotoChild( inName )== false )
+ {
+ XmlNode* newNode = allocateRepXNode( &mManager, inName, NULL );
+ mCurrentNode->addChild( newNode );
+ mCurrentNode = newNode;
+ }
+ }
+ virtual void setCurrentItemValue( const char* inValue )
+ {
+ mCurrentNode->mData = copyStr( &mManager, inValue );
+ }
+ virtual bool removeChild( const char* name )
+ {
+ XmlNode* theChild( mCurrentNode->findChildByName( name ) );
+ if ( theChild )
+ {
+ releaseNodeAndChildren( &mManager, theChild );
+ return true;
+ }
+ return false;
+ }
+ virtual void release() { this->~XmlNodeReader(); mWrapper.getAllocator().deallocate(this); }
+
+ private:
+ XmlNodeReader& operator=(const XmlNodeReader&);
+ };
+
+ PX_INLINE void freeNodeAndChildren( XmlNode* tempNode, TMemoryPoolManager& inManager )
+ {
+ for( XmlNode* theNode = tempNode->mFirstChild; theNode != NULL; theNode = theNode->mNextSibling )
+ freeNodeAndChildren( theNode, inManager );
+ tempNode->orphan();
+ release( &inManager, tempNode );
+ }
+
+ class XmlParser : public Ps::FastXml::Callback
+ {
+ XmlParseArgs mParseArgs;
+ //For parse time only allocations
+ XmlMemoryAllocatorImpl& mParseAllocator;
+ XmlNode* mCurrentNode;
+ XmlNode* mTopNode;
+
+ public:
+ XmlParser( XmlParseArgs inArgs, XmlMemoryAllocatorImpl& inParseAllocator )
+ : mParseArgs( inArgs )
+ , mParseAllocator( inParseAllocator )
+ , mCurrentNode( NULL )
+ , mTopNode( NULL )
+ {
+ }
+
+ virtual ~XmlParser(){}
+
+ virtual bool processComment(const char* /*comment*/) { return true; }
+ // 'element' is the name of the element that is being closed.
+ // depth is the recursion depth of this element.
+ // Return true to continue processing the XML file.
+ // Return false to stop processing the XML file; leaves the read pointer of the stream right after this close tag.
+ // The bool 'isError' indicates whether processing was stopped due to an error, or intentionally canceled early.
+ virtual bool processClose(const char* /*element*/,physx::PxU32 /*depth*/,bool& /*isError*/)
+ {
+ mCurrentNode = mCurrentNode->mParent;
+ return true;
+ }
+
+ // return true to continue processing the XML document, false to skip.
+ virtual bool processElement(
+ const char *elementName, // name of the element
+ const char *elementData, // element data, null if none
+ const Ps::FastXml::AttributePairs& attr, // attributes
+ PxI32 /*lineno*/)
+ {
+ XmlNode* newNode = allocateRepXNode( &mParseAllocator.mManager, elementName, elementData );
+ if ( mCurrentNode )
+ mCurrentNode->addChild( newNode );
+ mCurrentNode = newNode;
+ //Add the elements as children.
+ for( PxI32 item = 0; item < attr.getNbAttr(); item ++ )
+ {
+ XmlNode* node = allocateRepXNode( &mParseAllocator.mManager, attr.getKey(PxU32(item)), attr.getValue(PxU32(item)) );
+ mCurrentNode->addChild( node );
+ }
+ if ( mTopNode == NULL ) mTopNode = newNode;
+ return true;
+ }
+
+ XmlNode* getTopNode() { return mTopNode; }
+
+ virtual void * allocate(PxU32 size)
+ {
+ if ( size )
+ return mParseAllocator.allocate(size);
+ return NULL;
+ }
+ virtual void deallocate(void *mem)
+ {
+ if ( mem )
+ mParseAllocator.deallocate(reinterpret_cast<PxU8*>(mem));
+ }
+
+ private:
+ XmlParser& operator=(const XmlParser&);
+ };
+
+ struct RepXCollectionSharedData
+ {
+ PxProfileAllocatorWrapper mWrapper;
+ XmlMemoryAllocatorImpl mAllocator;
+ PxU32 mRefCount;
+
+ RepXCollectionSharedData( PxAllocatorCallback& inAllocator )
+ : mWrapper( inAllocator )
+ , mAllocator( inAllocator )
+ , mRefCount( 0 )
+ {
+ }
+ ~RepXCollectionSharedData() {}
+
+ void addRef() { ++mRefCount;}
+ void release()
+ {
+ if ( mRefCount ) --mRefCount;
+ if ( !mRefCount ) { this->~RepXCollectionSharedData(); mWrapper.getAllocator().deallocate(this);}
+ }
+ };
+
+ struct SharedDataPtr
+ {
+ RepXCollectionSharedData* mData;
+ SharedDataPtr( RepXCollectionSharedData* inData )
+ : mData( inData )
+ {
+ mData->addRef();
+ }
+ SharedDataPtr( const SharedDataPtr& inOther )
+ : mData( inOther.mData )
+ {
+ mData->addRef();
+ }
+ SharedDataPtr& operator=( const SharedDataPtr& inOther );
+ ~SharedDataPtr()
+ {
+ mData->release();
+ mData = NULL;
+ }
+ RepXCollectionSharedData* operator->() { return mData; }
+ const RepXCollectionSharedData* operator->() const { return mData; }
+ };
+
+ class RepXCollectionImpl : public RepXCollection, public Ps::UserAllocated
+ {
+ SharedDataPtr mSharedData;
+
+ XmlMemoryAllocatorImpl& mAllocator;
+ PxSerializationRegistry& mSerializationRegistry;
+ PxProfileArray<RepXCollectionItem> mCollection;
+ TMemoryPoolManager mSerializationManager;
+ MemoryBuffer mPropertyBuffer;
+ PxTolerancesScale mScale;
+ PxVec3 mUpVector;
+ const char* mVersionStr;
+ PxCollection* mPxCollection;
+
+ public:
+ RepXCollectionImpl( PxSerializationRegistry& inRegistry, PxAllocatorCallback& inAllocator, PxCollection& inPxCollection )
+ : mSharedData( &PX_NEW_REPX_SERIALIZER( RepXCollectionSharedData ))
+ , mAllocator( mSharedData->mAllocator )
+ , mSerializationRegistry( inRegistry )
+ , mCollection( mSharedData->mWrapper )
+ , mSerializationManager( inAllocator )
+ , mPropertyBuffer( &mSerializationManager )
+ , mUpVector( 0,0,0 )
+ , mVersionStr( getLatestVersion() )
+ , mPxCollection( &inPxCollection )
+ {
+ memset( &mScale, 0, sizeof( PxTolerancesScale ) );
+ PX_ASSERT( mScale.isValid() == false );
+ }
+
+ RepXCollectionImpl( PxSerializationRegistry& inRegistry, const RepXCollectionImpl& inSrc, const char* inNewVersion )
+ : mSharedData( inSrc.mSharedData )
+ , mAllocator( mSharedData->mAllocator )
+ , mSerializationRegistry( inRegistry )
+ , mCollection( mSharedData->mWrapper )
+ , mSerializationManager( mSharedData->mWrapper.getAllocator() )
+ , mPropertyBuffer( &mSerializationManager )
+ , mScale( inSrc.mScale )
+ , mUpVector( inSrc.mUpVector )
+ , mVersionStr( inNewVersion )
+ , mPxCollection( NULL )
+ {
+ }
+
+ virtual ~RepXCollectionImpl()
+ {
+ PxU32 numItems = mCollection.size();
+ for ( PxU32 idx = 0; idx < numItems; ++idx )
+ {
+ XmlNode* theNode = mCollection[idx].descriptor;
+ releaseNodeAndChildren( &mAllocator.mManager, theNode );
+ }
+ }
+ RepXCollectionImpl& operator=(const RepXCollectionImpl&);
+
+ virtual void destroy()
+ {
+ PxProfileAllocatorWrapper tempWrapper( mSharedData->mWrapper.getAllocator() );
+ this->~RepXCollectionImpl();
+ tempWrapper.getAllocator().deallocate(this);
+ }
+
+ virtual void setTolerancesScale(const PxTolerancesScale& inScale) { mScale = inScale; }
+ virtual PxTolerancesScale getTolerancesScale() const { return mScale; }
+ virtual void setUpVector( const PxVec3& inUpVector ) { mUpVector = inUpVector; }
+ virtual PxVec3 getUpVector() const { return mUpVector; }
+
+
+ PX_INLINE RepXCollectionItem findItemBySceneItem( const PxRepXObject& inObject ) const
+ {
+ //See if the object is in the collection
+ for ( PxU32 idx =0; idx < mCollection.size(); ++idx )
+ if ( mCollection[idx].liveObject.serializable == inObject.serializable )
+ return mCollection[idx];
+ return RepXCollectionItem();
+ }
+
+ virtual RepXAddToCollectionResult addRepXObjectToCollection( const PxRepXObject& inObject, PxCollection* inCollection, PxRepXInstantiationArgs& inArgs )
+ {
+ PX_ASSERT( inObject.serializable );
+ PX_ASSERT( inObject.id );
+ if ( inObject.serializable == NULL || inObject.id == 0 )
+ return RepXAddToCollectionResult( RepXAddToCollectionResult::InvalidParameters );
+
+ PxRepXSerializer* theSerializer = mSerializationRegistry.getRepXSerializer( inObject.typeName );
+ if ( theSerializer == NULL )
+ return RepXAddToCollectionResult( RepXAddToCollectionResult::SerializerNotFound );
+
+ RepXCollectionItem existing = findItemBySceneItem( inObject );
+ if ( existing.liveObject.serializable )
+ return RepXAddToCollectionResult( RepXAddToCollectionResult::AlreadyInCollection, existing.liveObject.id );
+
+ XmlNodeWriter theXmlWriter( mAllocator, 1 );
+ XmlWriterImpl theRepXWriter( &theXmlWriter, &mPropertyBuffer );
+ {
+ SimpleXmlWriter::STagWatcher theWatcher( theXmlWriter, inObject.typeName );
+ writeProperty( theXmlWriter, mPropertyBuffer, "Id", inObject.id );
+ theSerializer->objectToFile( inObject, inCollection, theRepXWriter, mPropertyBuffer,inArgs );
+ }
+ mCollection.pushBack( RepXCollectionItem( inObject, theXmlWriter.getTopNode() ) );
+ return RepXAddToCollectionResult( RepXAddToCollectionResult::Success, inObject.id );
+ }
+
+ virtual bool instantiateCollection( PxRepXInstantiationArgs& inArgs, PxCollection& inCollection )
+ {
+ for ( PxU32 idx =0; idx < mCollection.size(); ++idx )
+ {
+ RepXCollectionItem theItem( mCollection[idx] );
+ PxRepXSerializer* theSerializer = mSerializationRegistry.getRepXSerializer( theItem.liveObject.typeName );
+ if (theSerializer )
+ {
+ XmlNodeReader theReader( theItem.descriptor, mAllocator.getAllocator(), mAllocator.mManager );
+ XmlMemoryAllocatorImpl instantiationAllocator( mAllocator.getAllocator() );
+ PxRepXObject theLiveObject = theSerializer->fileToObject( theReader, instantiationAllocator, inArgs, &inCollection );
+ if (theLiveObject.isValid())
+ {
+ const PxBase* s = reinterpret_cast<const PxBase*>( theLiveObject.serializable ) ;
+ inCollection.add( *const_cast<PxBase*>(s), PxSerialObjectId( theItem.liveObject.id ));
+ }
+ else
+ return false;
+ }
+ else
+ {
+ Ps::getFoundation().error(PxErrorCode::eINTERNAL_ERROR, __FILE__, __LINE__,
+ "PxSerialization::createCollectionFromXml: "
+ "PxRepXSerializer missing for type %s", theItem.liveObject.typeName);
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ void saveXmlNode( XmlNode* inNode, SimpleXmlWriter& inWriter )
+ {
+ XmlNode* theNode( inNode );
+ if ( theNode->mData && *theNode->mData && theNode->mFirstChild == NULL )
+ inWriter.writeContentTag( theNode->mName, theNode->mData );
+ else
+ {
+ inWriter.beginTag( theNode->mName );
+ if ( theNode->mData && *theNode->mData )
+ inWriter.addContent( theNode->mData );
+ for ( XmlNode* theChild = theNode->mFirstChild;
+ theChild != NULL;
+ theChild = theChild->mNextSibling )
+ saveXmlNode( theChild, inWriter );
+ inWriter.endTag();
+ }
+ }
+
+ virtual void save( PxOutputStream& inStream )
+ {
+ SimpleXmlWriterImpl<PxOutputStream> theWriter( inStream, mAllocator.getAllocator() );
+ theWriter.beginTag( "PhysX30Collection" );
+ theWriter.addAttribute( "version", mVersionStr );
+ {
+ XmlWriterImpl theRepXWriter( &theWriter, &mPropertyBuffer );
+ writeProperty( theWriter, mPropertyBuffer, "UpVector", mUpVector );
+ theRepXWriter.addAndGotoChild( "Scale" );
+ writeAllProperties( &mScale, theRepXWriter, mPropertyBuffer, *mPxCollection);
+ theRepXWriter.leaveChild();
+ }
+ for ( PxU32 idx =0; idx < mCollection.size(); ++idx )
+ {
+ RepXCollectionItem theItem( mCollection[idx] );
+ XmlNode* theNode( theItem.descriptor );
+ saveXmlNode( theNode, theWriter );
+ }
+ }
+
+ void load( PxInputData& inFileBuf, SerializationRegistry& s )
+ {
+ inFileBuf.seek(0);
+ XmlParser theParser( XmlParseArgs( &mAllocator, &mCollection ), mAllocator );
+ Ps::FastXml* theFastXml = Ps::createFastXml( &theParser );
+ theFastXml->processXml( inFileBuf );
+ XmlNode* theTopNode = theParser.getTopNode();
+ if ( theTopNode != NULL )
+ {
+ {
+
+ XmlMemoryAllocatorImpl instantiationAllocator( mAllocator.getAllocator() );
+ XmlNodeReader theReader( theTopNode, mAllocator.getAllocator(), mAllocator.mManager );
+ readProperty( theReader, "UpVector", mUpVector );
+ if ( theReader.gotoChild( "Scale" ) )
+ {
+ readAllProperties( PxRepXInstantiationArgs( s.getPhysics() ), theReader, &mScale, instantiationAllocator, *mPxCollection);
+ theReader.leaveChild();
+ }
+ const char* verStr = NULL;
+ if ( theReader.read( "version", verStr ) )
+ mVersionStr = verStr;
+ }
+ for ( XmlNode* theChild = theTopNode->mFirstChild;
+ theChild != NULL;
+ theChild = theChild->mNextSibling )
+ {
+ if ( physx::shdfnd::stricmp( theChild->mName, "scale" ) == 0
+ || physx::shdfnd::stricmp( theChild->mName, "version" ) == 0
+ || physx::shdfnd::stricmp( theChild->mName, "upvector" ) == 0 )
+ continue;
+ XmlNodeReader theReader( theChild, mAllocator.getAllocator(), mAllocator.mManager );
+ PxRepXObject theObject;
+ theObject.typeName = theChild->mName;
+ theObject.serializable = NULL;
+ PxSerialObjectId theId = 0;
+ theReader.read( "Id", theId );
+ theObject.id = theId;
+ mCollection.pushBack( RepXCollectionItem( theObject, theChild ) );
+ }
+ }
+ else
+ {
+ Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__,
+ "Cannot parse any object from the input buffer, please check the input repx data.");
+ }
+ theFastXml->release();
+ }
+
+ virtual const char* getVersion() { return mVersionStr; }
+
+ virtual const RepXCollectionItem* begin() const
+ {
+ return mCollection.begin();
+ }
+ virtual const RepXCollectionItem* end() const
+ {
+ return mCollection.end();
+ }
+
+ virtual RepXCollection& createCollection( const char* inVersionStr )
+ {
+ PxAllocatorCallback& allocator = mSharedData->mWrapper.getAllocator();
+ RepXCollectionImpl* retval = PX_PLACEMENT_NEW((allocator.allocate(sizeof(RepXCollectionImpl), "createCollection", __FILE__, __LINE__ )), RepXCollectionImpl) ( mSerializationRegistry, *this, inVersionStr );
+
+ return *retval;
+ }
+
+ //Performs a deep copy of the repx node.
+ virtual XmlNode* copyRepXNode( const XmlNode* srcNode )
+ {
+ return physx::Sn::copyRepXNode( &mAllocator.mManager, srcNode );
+ }
+
+ virtual void addCollectionItem( RepXCollectionItem inItem )
+ {
+ mCollection.pushBack( inItem );
+ }
+
+ virtual PxAllocatorCallback& getAllocator() { return mSharedData->mAllocator.getAllocator(); }
+ //Create a new repx node with this name. Its value is unset.
+ virtual XmlNode& createRepXNode( const char* name )
+ {
+ XmlNode* newNode = allocateRepXNode( &mSharedData->mAllocator.mManager, name, NULL );
+ return *newNode;
+ }
+
+ //Release this when finished.
+ virtual XmlReaderWriter& createNodeEditor()
+ {
+ PxAllocatorCallback& allocator = mSharedData->mWrapper.getAllocator();
+ XmlReaderWriter* retval = PX_PLACEMENT_NEW((allocator.allocate(sizeof(XmlNodeReader), "createNodeEditor", __FILE__, __LINE__ )), XmlNodeReader) ( NULL, allocator, mAllocator.mManager );
+ return *retval;
+ }
+ };
+
+ const char* RepXCollection::getLatestVersion()
+ {
+#define TOSTR_(x) #x
+#define CONCAT_(a, b, c) TOSTR_(a.##b.##c)
+#define MAKE_VERSION_STR(a,b,c) CONCAT_(a, b, c)
+
+ return MAKE_VERSION_STR(PX_PHYSICS_VERSION_MAJOR,PX_PHYSICS_VERSION_MINOR,PX_PHYSICS_VERSION_BUGFIX);
+
+ }
+
+ static RepXCollection* create(SerializationRegistry& s, PxAllocatorCallback& inAllocator, PxCollection& inCollection )
+ {
+ return PX_PLACEMENT_NEW((inAllocator.allocate(sizeof(RepXCollectionImpl), "RepXCollection::create", __FILE__, __LINE__ )), RepXCollectionImpl) ( s, inAllocator, inCollection );
+ }
+
+ static RepXCollection* create(SerializationRegistry& s, PxInputData &data, PxAllocatorCallback& inAllocator, PxCollection& inCollection )
+ {
+ RepXCollectionImpl* theCollection = static_cast<RepXCollectionImpl*>( create(s, inAllocator, inCollection ) );
+ theCollection->load( data, s );
+ return theCollection;
+ }
+}
+
+ bool PxSerialization::serializeCollectionToXml( PxOutputStream& outputStream, PxCollection& collection, PxSerializationRegistry& sr, PxCooking* cooking, const PxCollection* externalRefs, PxXmlMiscParameter* inArgs )
+ {
+ if( !PxSerialization::isSerializable(collection, sr, const_cast<PxCollection*>(externalRefs)) )
+ return false;
+
+ bool bRet = true;
+
+ SerializationRegistry& sn = static_cast<SerializationRegistry&>(sr);
+ PxRepXInstantiationArgs args( sn.getPhysics(), cooking );
+
+ PxCollection* tmpCollection = PxCreateCollection();
+ PX_ASSERT(tmpCollection);
+
+ tmpCollection->add( collection );
+ if(externalRefs)
+ {
+ tmpCollection->add(*const_cast<PxCollection*>(externalRefs));
+ }
+
+ PxAllocatorCallback& allocator = PxGetFoundation().getAllocatorCallback();
+ Sn::RepXCollection* theRepXCollection = Sn::create(sn, allocator, *tmpCollection );
+
+ if(inArgs != NULL)
+ {
+ theRepXCollection->setTolerancesScale(inArgs->scale);
+ theRepXCollection->setUpVector(inArgs->upVector);
+ }
+
+ PxU32 nbObjects = collection.getNbObjects();
+ if( nbObjects )
+ {
+ sortCollection( static_cast<Cm::Collection&>(collection), sn, true);
+
+ for( PxU32 i = 0; i < nbObjects; i++ )
+ {
+ PxBase& s = collection.getObject(i);
+ if( PxConcreteType::eSHAPE == s.getConcreteType() )
+ {
+ PxShape& shape = static_cast<PxShape&>(s);
+ if( shape.isExclusive() )
+ continue;
+ }
+
+ PxSerialObjectId id = collection.getId(s);
+ if(id == PX_SERIAL_OBJECT_ID_INVALID)
+ id = static_cast<PxSerialObjectId>( reinterpret_cast<size_t>( &s ));
+
+ PxRepXObject ro = PxCreateRepXObject( &s, id );
+ if ( ro.serializable == NULL || ro.id == 0 )
+ {
+ bRet = false;
+ break;
+ }
+
+ theRepXCollection->addRepXObjectToCollection( ro, tmpCollection, args );
+ }
+ }
+ tmpCollection->release();
+
+ theRepXCollection->save(outputStream);
+ theRepXCollection->destroy();
+
+
+ return bRet;
+ }
+
+ PxCollection* PxSerialization::createCollectionFromXml(PxInputData& inputData, PxCooking& cooking, PxSerializationRegistry& sr, const PxCollection* externalRefs, PxStringTable* stringTable, PxXmlMiscParameter* outArgs)
+ {
+ SerializationRegistry& sn = static_cast<SerializationRegistry&>(sr);
+ PxCollection* collection = PxCreateCollection();
+ PX_ASSERT(collection);
+
+ if( externalRefs )
+ collection->add(*const_cast<PxCollection*>(externalRefs));
+
+ PxAllocatorCallback& allocator = PxGetFoundation().getAllocatorCallback();
+ Sn::RepXCollection* theRepXCollection = Sn::create(sn, inputData, allocator, *collection);
+ theRepXCollection = &Sn::RepXUpgrader::upgradeCollection( *theRepXCollection );
+
+ PxRepXInstantiationArgs args( sn.getPhysics(), &cooking, stringTable );
+ if( !theRepXCollection->instantiateCollection(args, *collection) )
+ {
+ collection->release();
+ theRepXCollection->destroy();
+ return NULL;
+ }
+
+ if( externalRefs )
+ collection->remove(*const_cast<PxCollection*>(externalRefs));
+
+ if(outArgs != NULL)
+ {
+ outArgs->upVector = theRepXCollection->getUpVector();
+ outArgs->scale = theRepXCollection->getTolerancesScale();
+ }
+
+ theRepXCollection->destroy();
+
+ return collection;
+ }
+}
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerializer.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerializer.h
new file mode 100644
index 00000000..9effab4f
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSerializer.h
@@ -0,0 +1,117 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_SERIALIZER_H
+#define PX_XML_SERIALIZER_H
+
+#include "PxExtensionMetaDataObjects.h"
+#include "SnXmlVisitorWriter.h"
+
+namespace physx {
+
+namespace Sn {
+
+ void writeHeightFieldSample( PxOutputStream& inStream, const PxHeightFieldSample& inSample )
+ {
+ PxU32 retval = 0;
+ PxU8* writePtr( reinterpret_cast< PxU8*>( &retval ) );
+ const PxU8* inPtr( reinterpret_cast<const PxU8*>( &inSample ) );
+ if ( isBigEndian() )
+ {
+ //Height field samples are a
+ //16 bit integer followed by two bytes.
+ //right now, data is 2 1 3 4
+ //We need a 32 bit integer that
+ //when read in by a LE system is 4 3 2 1.
+ //Thus, we need a BE integer that looks like:
+ //4 3 2 1
+
+ writePtr[0] = inPtr[3];
+ writePtr[1] = inPtr[2];
+ writePtr[2] = inPtr[0];
+ writePtr[3] = inPtr[1];
+ }
+ else
+ {
+ writePtr[0] = inPtr[0];
+ writePtr[1] = inPtr[1];
+ writePtr[2] = inPtr[2];
+ writePtr[3] = inPtr[3];
+ }
+ inStream << retval;
+ }
+
+
+
+ template<typename TDataType, typename TWriteOperator>
+ inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const void* inData, PxU32 inStride, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inOperator )
+ {
+ PX_ASSERT( inStride == 0 || inStride == sizeof( TDataType ) );
+ PX_UNUSED( inStride );
+ writeBuffer( writer, tempBuffer
+ , inItemsPerLine, reinterpret_cast<const TDataType*>( inData )
+ , inCount, inPropName, inOperator );
+ }
+
+ template<typename TDataType, typename TWriteOperator>
+ inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const PxStridedData& inData, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inOperator )
+ {
+ writeStridedBufferProperty<TDataType>( writer, tempBuffer, inPropName, inData.data, inData.stride, inCount, inItemsPerLine, inOperator );
+ }
+
+ template<typename TDataType, typename TWriteOperator>
+ inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const PxTypedStridedData<TDataType>& inData, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inOperator )
+ {
+ writeStridedBufferProperty<TDataType>( writer, tempBuffer, inPropName, inData.data, inData.stride, inCount, inItemsPerLine, inOperator );
+ }
+
+ template<typename TDataType, typename TWriteOperator>
+ inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const PxBoundedData& inData, PxU32 inItemsPerLine, TWriteOperator inWriteOperator )
+ {
+ writeStridedBufferProperty<TDataType>( writer, tempBuffer, inPropName, inData, inData.count, inItemsPerLine, inWriteOperator );
+ }
+
+ template<typename TDataType, typename TWriteOperator>
+ inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, PxStrideIterator<const TDataType>& inData, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inWriteOperator )
+ {
+ writeStrideBuffer<TDataType>(writer, tempBuffer
+ , inItemsPerLine, inData, PtrAccess<TDataType>
+ , inCount, inPropName, inData.stride(), inWriteOperator );
+ }
+
+ template<typename TDataType>
+ inline void writeStridedFlagsProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, PxStrideIterator<const TDataType>& inData, PxU32 inCount, PxU32 inItemsPerLine, const PxU32ToName* inTable )
+ {
+ writeStrideFlags<TDataType>(writer, tempBuffer
+ , inItemsPerLine, inData, PtrAccess<TDataType>
+ , inCount, inPropName, inTable );
+ }
+
+}
+}
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSimpleXmlWriter.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSimpleXmlWriter.h
new file mode 100644
index 00000000..7ee771b8
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlSimpleXmlWriter.h
@@ -0,0 +1,215 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_SIMPLEXMLWRITER_H
+#define PX_SIMPLEXMLWRITER_H
+
+#include "PsArray.h"
+#include "SnXmlMemoryPoolStreams.h"
+#include "CmPhysXCommon.h"
+
+namespace physx { namespace Sn {
+ class XmlWriter
+ {
+ public:
+
+ struct STagWatcher
+ {
+ typedef XmlWriter TXmlWriterType;
+ TXmlWriterType& mWriter;
+ STagWatcher( const STagWatcher& inOther );
+ STagWatcher& operator-( const STagWatcher& inOther );
+ STagWatcher( TXmlWriterType& inWriter, const char* inTagName )
+ : mWriter( inWriter )
+ {
+ mWriter.beginTag( inTagName );
+ }
+ ~STagWatcher() { mWriter.endTag(); }
+ };
+
+ virtual ~XmlWriter(){}
+ virtual void beginTag( const char* inTagname ) = 0;
+ virtual void endTag() = 0;
+ virtual void addAttribute( const char* inName, const char* inValue ) = 0;
+ virtual void writeContentTag( const char* inTag, const char* inContent ) = 0;
+ virtual void addContent( const char* inContent ) = 0;
+ virtual PxU32 tabCount() = 0;
+ };
+
+ template<typename TStreamType>
+ class XmlWriterImpl : public XmlWriter
+ {
+ PxProfileAllocatorWrapper mWrapper;
+ TStreamType& mStream;
+ XmlWriterImpl( const XmlWriterImpl& inOther );
+ XmlWriterImpl& operator=( const XmlWriterImpl& inOther );
+ PxProfileArray<const char*> mTags;
+ bool mTagOpen;
+ PxU32 mInitialTagDepth;
+ public:
+
+ XmlWriterImpl( TStreamType& inStream, PxAllocatorCallback& inAllocator, PxU32 inInitialTagDepth = 0 )
+ : mWrapper( inAllocator )
+ , mStream( inStream )
+ , mTags( mWrapper )
+ , mTagOpen( false )
+ , mInitialTagDepth( inInitialTagDepth )
+ {
+ }
+ virtual ~XmlWriterImpl()
+ {
+ while( mTags.size() )
+ endTag();
+ }
+ PxU32 tabCount() { return mTags.size() + mInitialTagDepth; }
+
+ void writeTabs( PxU32 inSize )
+ {
+ inSize += mInitialTagDepth;
+ for ( PxU32 idx =0; idx < inSize; ++idx )
+ mStream << "\t";
+ }
+ void beginTag( const char* inTagname )
+ {
+ closeTag();
+ writeTabs(mTags.size());
+ mTags.pushBack( inTagname );
+ mStream << "<" << inTagname;
+ mTagOpen = true;
+ }
+ void addAttribute( const char* inName, const char* inValue )
+ {
+ PX_ASSERT( mTagOpen );
+ mStream << " " << inName << "=" << "\"" << inValue << "\"";
+ }
+ void closeTag(bool useNewline = true)
+ {
+ if ( mTagOpen )
+ {
+ mStream << " " << ">";
+ if (useNewline )
+ mStream << "\n";
+ }
+ mTagOpen = false;
+ }
+ void doEndOpenTag()
+ {
+ mStream << "</" << mTags.back() << ">" << "\n";
+ }
+ void endTag()
+ {
+ PX_ASSERT( mTags.size() );
+ if ( mTagOpen )
+ mStream << " " << "/>" << "\n";
+ else
+ {
+ writeTabs(mTags.size()-1);
+ doEndOpenTag();
+ }
+ mTagOpen = false;
+ mTags.popBack();
+ }
+ void addContent( const char* inContent )
+ {
+ closeTag(false);
+ mStream << inContent;
+ }
+ void writeContentTag( const char* inTag, const char* inContent )
+ {
+ beginTag( inTag );
+ addContent( inContent );
+ doEndOpenTag();
+ mTags.popBack();
+ }
+ void insertXml( const char* inXml )
+ {
+ closeTag();
+ mStream << inXml;
+ }
+ };
+
+ struct BeginTag
+ {
+ const char* mTagName;
+ BeginTag( const char* inTagName )
+ : mTagName( inTagName ) { }
+ };
+
+ struct EndTag
+ {
+ EndTag() {}
+ };
+
+ struct Att
+ {
+ const char* mAttName;
+ const char* mAttValue;
+ Att( const char* inAttName, const char* inAttValue )
+ : mAttName( inAttName )
+ , mAttValue( inAttValue ) { }
+ };
+
+ struct Content
+ {
+ const char* mContent;
+ Content( const char* inContent )
+ : mContent( inContent ) { }
+ };
+
+
+ struct ContentTag
+ {
+ const char* mTagName;
+ const char* mContent;
+ ContentTag( const char* inTagName, const char* inContent )
+ : mTagName( inTagName )
+ , mContent( inContent ) { }
+ };
+
+ inline XmlWriter& operator<<( XmlWriter& inWriter, const BeginTag& inTag ) { inWriter.beginTag( inTag.mTagName ); return inWriter; }
+ inline XmlWriter& operator<<( XmlWriter& inWriter, const EndTag& inTag ) { inWriter.endTag(); return inWriter; }
+ inline XmlWriter& operator<<( XmlWriter& inWriter, const Att& inTag ) { inWriter.addAttribute(inTag.mAttName, inTag.mAttValue); return inWriter; }
+ inline XmlWriter& operator<<( XmlWriter& inWriter, const Content& inTag ) { inWriter.addContent(inTag.mContent); return inWriter; }
+ inline XmlWriter& operator<<( XmlWriter& inWriter, const ContentTag& inTag ) { inWriter.writeContentTag(inTag.mTagName, inTag.mContent); return inWriter; }
+
+ inline void writeProperty( XmlWriter& inWriter, MemoryBuffer& tempBuffer, const char* inPropName )
+ {
+ PxU8 data = 0;
+ tempBuffer.write( &data, sizeof(PxU8) );
+ inWriter.writeContentTag( inPropName, reinterpret_cast<const char*>( tempBuffer.mBuffer ) );
+ tempBuffer.clear();
+ }
+
+ template<typename TDataType>
+ inline void writeProperty( XmlWriter& inWriter, MemoryBuffer& tempBuffer, const char* inPropName, TDataType inValue )
+ {
+ tempBuffer << inValue;
+ writeProperty( inWriter, tempBuffer, inPropName );
+ }
+} }
+#endif \ No newline at end of file
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlStringToType.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlStringToType.h
new file mode 100644
index 00000000..0361a2bf
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlStringToType.h
@@ -0,0 +1,275 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_STRINGTOTYPE_H
+#define PX_XML_STRINGTOTYPE_H
+
+#include <stdio.h>
+#include <ctype.h>
+#include "PsString.h"
+#include "PxCoreUtilityTypes.h"
+#include "PxFiltering.h"
+
+//Remapping function name for gcc-based systems.
+#ifndef _MSC_VER
+#define _strtoui64 strtoull
+#endif
+
+
+namespace physx { namespace Sn {
+
+ template<typename TDataType>
+ struct StrToImpl
+ {
+ bool compile_error;
+ };
+
+ template<> struct StrToImpl<PxU64> {
+ //Id's (void ptrs) are written to file as unsigned
+ //64 bit integers, so this method gets called more
+ //often than one might think.
+ PX_INLINE void strto( PxU64& ioDatatype,const char*& ioData )
+ {
+ ioDatatype = _strtoui64( ioData, const_cast<char **>(&ioData), 10 );
+ }
+ };
+
+ PX_INLINE PxF32 strToFloat(const char *str,const char **nextScan)
+ {
+ PxF32 ret;
+ while ( *str && isspace(static_cast<unsigned char>(*str))) str++; // skip leading whitespace
+ char temp[256] = "";
+ char *dest = temp;
+ char *end = &temp[255];
+ const char *begin = str;
+ while ( *str && !isspace(static_cast<unsigned char>(*str)) && dest < end ) // copy the number up to the first whitespace or eos
+ {
+ *dest++ = *str++;
+ }
+ *dest = 0;
+ ret = PxF32(strtod(temp,&end));
+ if ( nextScan )
+ {
+ *nextScan = begin+(end-temp);
+ }
+ return ret;
+ }
+
+
+ template<> struct StrToImpl<PxU32> {
+ PX_INLINE void strto( PxU32& ioDatatype,const char*& ioData )
+ {
+ ioDatatype = static_cast<PxU32>( strtoul( ioData,const_cast<char **>(&ioData), 10 ) );
+ }
+ };
+
+ template<> struct StrToImpl<PxI32> {
+ PX_INLINE void strto( PxI32& ioDatatype,const char*& ioData )
+ {
+ ioDatatype = static_cast<PxI32>( strtoul( ioData,const_cast<char **>(&ioData), 10 ) );
+ }
+ };
+
+
+ template<> struct StrToImpl<PxU16> {
+ PX_INLINE void strto( PxU16& ioDatatype,const char*& ioData )
+ {
+ ioDatatype = static_cast<PxU16>( strtoul( ioData,const_cast<char **>(&ioData), 10 ) );
+ }
+ };
+
+ PX_INLINE void eatwhite(const char*& ioData )
+ {
+ if ( ioData )
+ {
+ while( isspace( static_cast<unsigned char>(*ioData) ) )
+ ++ioData;
+ }
+ }
+
+ // copy the source data to the dest buffer until the first whitespace is encountered.
+ // Do not overflow the buffer based on the bufferLen provided.
+ // Advance the input 'ioData' pointer so that it sits just at the next whitespace
+ PX_INLINE void nullTerminateWhite(const char*& ioData,char *buffer,PxU32 bufferLen)
+ {
+ if ( ioData )
+ {
+ char *eof = buffer+(bufferLen-1);
+ char *dest = buffer;
+ while( *ioData && !isspace(static_cast<unsigned char>(*ioData)) && dest < eof )
+ {
+ *dest++ = *ioData++;
+ }
+ *dest = 0;
+ }
+ }
+
+ inline void nonNullTerminateWhite(const char*& ioData )
+ {
+ if ( ioData )
+ {
+ while( *ioData && !isspace( static_cast<unsigned char>(*ioData) ) )
+ ++ioData;
+ }
+ }
+
+ template<> struct StrToImpl<PxF32> {
+ inline void strto( PxF32& ioDatatype,const char*& ioData )
+ {
+ ioDatatype = strToFloat(ioData,&ioData);
+ }
+
+ };
+
+
+ template<> struct StrToImpl<void*> {
+ inline void strto( void*& ioDatatype,const char*& ioData )
+ {
+ PxU64 theData;
+ StrToImpl<PxU64>().strto( theData, ioData );
+ ioDatatype = reinterpret_cast<void*>( static_cast<size_t>( theData ) );
+ }
+ };
+
+
+ template<> struct StrToImpl<physx::PxVec3> {
+ inline void strto( physx::PxVec3& ioDatatype,const char*& ioData )
+ {
+ StrToImpl<PxF32>().strto( ioDatatype[0], ioData );
+ StrToImpl<PxF32>().strto( ioDatatype[1], ioData );
+ StrToImpl<PxF32>().strto( ioDatatype[2], ioData );
+ }
+ };
+
+ template<> struct StrToImpl<PxU8*> {
+ inline void strto( PxU8*& /*ioDatatype*/,const char*& /*ioData*/)
+ {
+ }
+ };
+
+ template<> struct StrToImpl<bool> {
+ inline void strto( bool& ioType,const char*& inValue )
+ {
+ ioType = physx::shdfnd::stricmp( inValue, "true" ) == 0 ? true : false;
+ }
+ };
+
+ template<> struct StrToImpl<PxU8> {
+ PX_INLINE void strto( PxU8& ioType,const char* & inValue)
+ {
+ ioType = static_cast<PxU8>( strtoul( inValue,const_cast<char **>(&inValue), 10 ) );
+ }
+ };
+
+ template<> struct StrToImpl<PxFilterData> {
+ PX_INLINE void strto( PxFilterData& ioType,const char*& inValue)
+ {
+ ioType.word0 = static_cast<PxU32>( strtoul( inValue,const_cast<char **>(&inValue), 10 ) );
+ ioType.word1 = static_cast<PxU32>( strtoul( inValue,const_cast<char **>(&inValue), 10 ) );
+ ioType.word2 = static_cast<PxU32>( strtoul( inValue,const_cast<char **>(&inValue), 10 ) );
+ ioType.word3 = static_cast<PxU32>( strtoul( inValue, NULL, 10 ) );
+ }
+ };
+
+
+ template<> struct StrToImpl<PxQuat> {
+ PX_INLINE void strto( PxQuat& ioType,const char*& inValue )
+ {
+ ioType.x = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.y = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.z = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.w = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ }
+ };
+
+ template<> struct StrToImpl<PxTransform> {
+ PX_INLINE void strto( PxTransform& ioType,const char*& inValue)
+ {
+ ioType.q.x = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.q.y = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.q.z = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.q.w = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+
+ ioType.p[0] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.p[1] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.p[2] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ }
+ };
+
+ template<> struct StrToImpl<PxBounds3> {
+ PX_INLINE void strto( PxBounds3& ioType,const char*& inValue)
+ {
+ ioType.minimum[0] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.minimum[1] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.minimum[2] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+
+ ioType.maximum[0] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.maximum[1] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.maximum[2] = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ }
+ };
+
+ template<> struct StrToImpl<PxMetaDataPlane> {
+ PX_INLINE void strto( PxMetaDataPlane& ioType,const char*& inValue)
+ {
+ ioType.normal.x = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.normal.y = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.normal.z = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ ioType.distance = static_cast<PxReal>( strToFloat( inValue, &inValue ) );
+ }
+ };
+
+
+ template<> struct StrToImpl<PxRigidDynamic*> {
+ PX_INLINE void strto( PxRigidDynamic*& /*ioDatatype*/,const char*& /*ioData*/)
+ {
+ }
+ };
+
+ template<typename TDataType>
+ inline void strto( TDataType& ioType,const char*& ioData )
+ {
+ if ( ioData && *ioData ) StrToImpl<TDataType>().strto( ioType, ioData );
+ }
+
+ template<typename TDataType>
+ inline void strtoLong( TDataType& ioType,const char*& ioData )
+ {
+ if ( ioData && *ioData ) StrToImpl<TDataType>().strto( ioType, ioData );
+ }
+
+ template<typename TDataType>
+ inline void stringToType( const char* inValue, TDataType& ioType )
+ {
+ const char* theValue( inValue );
+ return strto( ioType, theValue );
+ }
+
+} }
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorReader.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorReader.h
new file mode 100644
index 00000000..e003edf0
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorReader.h
@@ -0,0 +1,889 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_VISITOR_READER_H
+#define PX_XML_VISITOR_READER_H
+
+#include "PsArray.h"
+#include "PsUtilities.h"
+#include "RepXMetaDataPropertyVisitor.h"
+#include "SnPxStreamOperators.h"
+#include "SnXmlMemoryPoolStreams.h"
+#include "SnXmlReader.h"
+#include "SnXmlImpl.h"
+#include "SnXmlMemoryAllocator.h"
+#include "SnXmlStringToType.h"
+
+namespace physx { namespace Sn {
+
+
+ inline PxU32 findEnumByName( const char* inName, const PxU32ToName* inTable )
+ {
+ for ( PxU32 idx = 0; inTable[idx].mName != NULL; ++idx )
+ {
+ if ( physx::shdfnd::stricmp( inTable[idx].mName, inName ) == 0 )
+ return inTable[idx].mValue;
+ }
+ return 0;
+ }
+
+ PX_INLINE void stringToFlagsType( const char* strData, XmlMemoryAllocator& alloc, PxU32& ioType, const PxU32ToName* inTable )
+ {
+ if ( inTable == NULL )
+ return;
+ ioType = 0;
+ if ( strData && *strData)
+ {
+ //Destructively parse the string to get out the different flags.
+ char* theValue = const_cast<char*>( copyStr( &alloc, strData ) );
+ char* theMarker = theValue;
+ char* theNext = theValue;
+ while( theNext && *theNext )
+ {
+ ++theNext;
+ if( *theNext == '|' )
+ {
+ *theNext = 0;
+ ++theNext;
+ ioType |= static_cast< PxU32 > ( findEnumByName( theMarker, inTable ) );
+ theMarker = theNext;
+ }
+ }
+ if ( theMarker && *theMarker )
+ ioType |= static_cast< PxU32 > ( findEnumByName( theMarker, inTable ) );
+ alloc.deallocate( reinterpret_cast<PxU8*>( theValue ) );
+ }
+ }
+
+ template<typename TDataType>
+ PX_INLINE void stringToEnumType( const char* strData, TDataType& ioType, const PxU32ToName* inTable )
+ {
+ ioType = static_cast<TDataType>( findEnumByName( strData, inTable ) );
+ }
+
+ template<typename TDataType>
+ PX_INLINE bool readProperty( XmlReader& inReader, const char* pname, TDataType& ioType )
+ {
+ const char* value;
+ if ( inReader.read( pname, value ) )
+ {
+ stringToType( value, ioType );
+ return true;
+ }
+ return false;
+ }
+
+ template<typename TObjType>
+ inline TObjType* findReferencedObject( PxCollection& collection, PxSerialObjectId id)
+ {
+ PX_ASSERT(id > 0);
+ TObjType* outObject = static_cast<TObjType*>(const_cast<PxBase*>(collection.find(id)));
+ if (outObject == NULL)
+ {
+ Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__,
+ "PxSerialization::createCollectionFromXml: "
+ "Reference to ID %d cannot be resolved. Make sure externalRefs collection is specified if required and "
+ "check Xml file for completeness.",
+ id);
+ }
+ return outObject;
+ }
+
+ template<typename TObjType>
+ inline bool readReference( XmlReader& inReader, PxCollection& collection, TObjType*& outObject )
+ {
+ PxSerialObjectId theId;
+ const char* theValue = inReader.getCurrentItemValue();
+ strto( theId, theValue );
+ if( theId == 0)
+ {
+ // the NULL pointer is a valid pointer if the input id is 0
+ outObject = NULL;
+ return true;
+ }
+ else
+ {
+ outObject = findReferencedObject<TObjType>(collection, theId);
+ return outObject != NULL;
+ }
+ }
+
+ template<typename TObjType>
+ inline bool readReference( XmlReader& inReader, PxCollection& inCollection, const char* pname, TObjType*& outObject )
+ {
+ outObject = NULL;
+ PxSerialObjectId theId = 0;
+ if (readProperty ( inReader, pname, theId ) && theId )
+ {
+ outObject = findReferencedObject<TObjType>(inCollection, theId);
+ }
+ // the NULL pointer is a valid pointer if the input id is 0
+ return (outObject != NULL) || 0 == theId;
+ }
+
+ template<typename TEnumType, typename TStorageType>
+ inline bool readFlagsProperty( XmlReader& reader, XmlMemoryAllocator& allocator, const char* pname, const PxU32ToName* inConversions, PxFlags<TEnumType,TStorageType>& outFlags )
+ {
+ const char* value;
+ if ( reader.read( pname, value ) )
+ {
+ PxU32 tempValue = 0;
+ stringToFlagsType( value, allocator, tempValue, inConversions );
+ outFlags = PxFlags<TEnumType,TStorageType>(Ps::to16(tempValue) );
+ return true;
+ }
+ return false;
+ }
+
+ template<typename TObjType, typename TReaderType, typename TInfoType>
+ inline void readComplexObj( TReaderType& oldVisitor, TObjType* inObj, TInfoType& info);
+ template<typename TObjType, typename TReaderType>
+ inline void readComplexObj( TReaderType& oldVisitor, TObjType* inObj);
+
+ template<typename TReaderType, typename TGeomType>
+ inline PxGeometry* parseGeometry( TReaderType& reader, TGeomType& /*inGeom*/)
+ {
+ PxAllocatorCallback& inAllocator = reader.mAllocator.getAllocator();
+
+ TGeomType* shape = PX_PLACEMENT_NEW((inAllocator.allocate(sizeof(TGeomType), "parseGeometry", __FILE__, __LINE__ )), TGeomType);
+ PxClassInfoTraits<TGeomType> info;
+ readComplexObj( reader, shape);
+ return shape;
+ }
+
+
+ template<typename TReaderType>
+ inline void parseShape( TReaderType& visitor, PxGeometry*& outResult, Ps::Array<PxMaterial*>& outMaterials)
+ {
+ XmlReader& theReader( visitor.mReader );
+ PxCollection& collection = visitor.mCollection;
+ visitor.pushCurrentContext();
+ if ( visitor.gotoTopName() )
+ {
+ visitor.pushCurrentContext();
+ if ( visitor.gotoChild( "Materials" ) )
+ {
+ for( bool matSuccess = visitor.gotoFirstChild(); matSuccess;
+ matSuccess = visitor.gotoNextSibling() )
+ {
+ PxMaterial* material = NULL;
+ if(!readReference<PxMaterial>( theReader, collection, material ))
+ visitor.mHadError = true;
+ if ( material )
+ outMaterials.pushBack( material );
+ }
+ }
+ visitor.popCurrentContext();
+ visitor.pushCurrentContext();
+
+ PxPlaneGeometry plane;
+ PxHeightFieldGeometry heightField;
+ PxSphereGeometry sphere;
+ PxTriangleMeshGeometry mesh;
+ PxConvexMeshGeometry convex;
+ PxBoxGeometry box;
+ PxCapsuleGeometry capsule;
+ if ( visitor.gotoChild( "Geometry" ) )
+ {
+ if ( visitor.gotoFirstChild() )
+ {
+ const char* geomTypeName = visitor.getCurrentItemName();
+
+ if ( physx::shdfnd::stricmp( geomTypeName, "PxSphereGeometry" ) == 0 ) outResult = parseGeometry(visitor, sphere);
+ else if ( physx::shdfnd::stricmp( geomTypeName, "PxPlaneGeometry" ) == 0 ) outResult = parseGeometry(visitor, plane);
+ else if ( physx::shdfnd::stricmp( geomTypeName, "PxCapsuleGeometry" ) == 0 ) outResult = parseGeometry(visitor, capsule);
+ else if ( physx::shdfnd::stricmp( geomTypeName, "PxBoxGeometry" ) == 0 ) outResult = parseGeometry(visitor, box);
+ else if ( physx::shdfnd::stricmp( geomTypeName, "PxConvexMeshGeometry" ) == 0 ) outResult = parseGeometry(visitor, convex);
+ else if ( physx::shdfnd::stricmp( geomTypeName, "PxTriangleMeshGeometry" ) == 0 ) outResult = parseGeometry(visitor, mesh);
+ else if ( physx::shdfnd::stricmp( geomTypeName, "PxHeightFieldGeometry" ) == 0 ) outResult = parseGeometry(visitor, heightField);
+ else
+ PX_ASSERT( false );
+ }
+ }
+ visitor.popCurrentContext();
+ }
+ visitor.popCurrentContext();
+
+ return;
+ }
+
+ template<typename TReaderType, typename TObjType>
+ inline void readShapesProperty( TReaderType& visitor, TObjType* inObj, const PxRigidActorShapeCollection* inProp = NULL, bool isSharedShape = false )
+ {
+ PX_UNUSED(isSharedShape);
+ PX_UNUSED(inProp);
+
+ XmlReader& theReader( visitor.mReader );
+ PxCollection& collection( visitor.mCollection );
+
+ visitor.pushCurrentContext();
+ if ( visitor.gotoTopName() )
+ {
+ //uggh working around the shape collection api.
+ //read out materials and geometry
+ for ( bool success = visitor.gotoFirstChild(); success;
+ success = visitor.gotoNextSibling() )
+ {
+ if( 0 == physx::shdfnd::stricmp( visitor.getCurrentItemName(), "PxShapeRef" ) )
+ {
+ PxShape* shape = NULL;
+ if(!readReference<PxShape>( theReader, collection, shape ))
+ visitor.mHadError = true;
+ if(shape)
+ inObj->attachShape( *shape );
+ }
+ else
+ {
+ Ps::Array<PxMaterial*> materials;
+ PxGeometry* geometry = NULL;
+ parseShape( visitor, geometry, materials);
+ PxShape* theShape = NULL;
+ if ( materials.size() )
+ {
+ theShape = visitor.mArgs.physics.createShape( *geometry, materials.begin(), Ps::to16(materials.size()), true );
+ if ( theShape )
+ {
+ readComplexObj( visitor, theShape );
+
+ if(theShape)
+ {
+ inObj->attachShape(*theShape);
+ collection.add( *theShape );
+ }
+ }
+ }
+
+ switch(geometry->getType())
+ {
+ case PxGeometryType::eSPHERE :
+ static_cast<PxSphereGeometry*>(geometry)->~PxSphereGeometry();
+ break;
+ case PxGeometryType::ePLANE :
+ static_cast<PxPlaneGeometry*>(geometry)->~PxPlaneGeometry();
+ break;
+ case PxGeometryType::eCAPSULE :
+ static_cast<PxCapsuleGeometry*>(geometry)->~PxCapsuleGeometry();
+ break;
+ case PxGeometryType::eBOX :
+ static_cast<PxBoxGeometry*>(geometry)->~PxBoxGeometry();
+ break;
+ case PxGeometryType::eCONVEXMESH :
+ static_cast<PxConvexMeshGeometry*>(geometry)->~PxConvexMeshGeometry();
+ break;
+ case PxGeometryType::eTRIANGLEMESH :
+ static_cast<PxTriangleMeshGeometry*>(geometry)->~PxTriangleMeshGeometry();
+ break;
+ case PxGeometryType::eHEIGHTFIELD :
+ static_cast<PxHeightFieldGeometry*>(geometry)->~PxHeightFieldGeometry();
+ break;
+
+ case PxGeometryType::eGEOMETRY_COUNT:
+ case PxGeometryType::eINVALID:
+ PX_ASSERT(0);
+ }
+ visitor.mAllocator.getAllocator().deallocate(geometry);
+ }
+ }
+ }
+ visitor.popCurrentContext();
+ }
+
+ struct ReaderNameStackEntry : NameStackEntry
+ {
+ bool mValid;
+ ReaderNameStackEntry( const char* nm, bool valid ) : NameStackEntry(nm), mValid(valid) {}
+ };
+
+ typedef PxProfileArray<ReaderNameStackEntry> TReaderNameStack;
+
+ template<typename TObjType>
+ struct RepXVisitorReaderBase
+ {
+
+ protected:
+ RepXVisitorReaderBase<TObjType>& operator=(const RepXVisitorReaderBase<TObjType>&);
+ public:
+ TReaderNameStack& mNames;
+ PxProfileArray<PxU32>& mContexts;
+ PxRepXInstantiationArgs mArgs;
+ XmlReader& mReader;
+ TObjType* mObj;
+ XmlMemoryAllocator& mAllocator;
+ PxCollection& mCollection;
+ bool mValid;
+ bool& mHadError;
+
+ RepXVisitorReaderBase( TReaderNameStack& names, PxProfileArray<PxU32>& contexts, const PxRepXInstantiationArgs& args, XmlReader& reader, TObjType* obj
+ , XmlMemoryAllocator& alloc, PxCollection& collection, bool& hadError )
+ : mNames( names )
+ , mContexts( contexts )
+ , mArgs( args )
+ , mReader( reader )
+ , mObj( obj )
+ , mAllocator( alloc )
+ , mCollection( collection )
+ , mValid( true )
+ , mHadError(hadError)
+ {
+ }
+ RepXVisitorReaderBase( const RepXVisitorReaderBase& other )
+ : mNames( other.mNames )
+ , mContexts( other.mContexts )
+ , mArgs( other.mArgs )
+ , mReader( other.mReader )
+ , mObj( other.mObj )
+ , mAllocator( other.mAllocator )
+ , mCollection( other.mCollection )
+ , mValid( other.mValid )
+ , mHadError( other.mHadError )
+ {
+ }
+
+
+ void pushName( const char* name )
+ {
+ gotoTopName();
+ mNames.pushBack( ReaderNameStackEntry( name, mValid ) );
+ }
+ void pushBracketedName( const char* name ) { pushName( name ); }
+ void popName()
+ {
+ if ( mNames.size() )
+ {
+ if ( mNames.back().mOpen && mNames.back().mValid )
+ mReader.leaveChild();
+ mNames.popBack();
+ }
+ mValid =true;
+ if ( mNames.size() && mNames.back().mValid == false )
+ mValid = false;
+ }
+
+ void pushCurrentContext()
+ {
+ mContexts.pushBack( static_cast<PxU32>( mNames.size() ) );
+ }
+ void popCurrentContext()
+ {
+ if ( mContexts.size() )
+ {
+ PxU32 depth = mContexts.back();
+ PX_ASSERT( mNames.size() >= depth );
+ while( mNames.size() > depth )
+ popName();
+ mContexts.popBack();
+ }
+ }
+
+ bool updateLastEntryAfterOpen()
+ {
+ mNames.back().mValid = mValid;
+ mNames.back().mOpen = mValid;
+ return mValid;
+ }
+
+ bool gotoTopName()
+ {
+ if ( mNames.size() && mNames.back().mOpen == false )
+ {
+ if ( mValid )
+ mValid = mReader.gotoChild( mNames.back().mName );
+ updateLastEntryAfterOpen();
+ }
+ return mValid;
+ }
+
+ bool isValid() const { return mValid; }
+
+ bool gotoChild( const char* name )
+ {
+ pushName( name );
+ return gotoTopName();
+ }
+
+ bool gotoFirstChild()
+ {
+ pushName( "__child" );
+ if ( mValid ) mValid = mReader.gotoFirstChild();
+ return updateLastEntryAfterOpen();
+ }
+
+ bool gotoNextSibling()
+ {
+ bool retval = mValid;
+ if ( mValid ) retval = mReader.gotoNextSibling();
+ return retval;
+ }
+
+ const char* getCurrentItemName() { if (mValid ) return mReader.getCurrentItemName(); return ""; }
+
+ const char* topName() const
+ {
+ if ( mNames.size() ) return mNames.back().mName;
+ PX_ASSERT( false );
+ return "bad__repx__name";
+ }
+
+ const char* getCurrentValue()
+ {
+ const char* value = NULL;
+ if ( isValid() && mReader.read( topName(), value ) )
+ return value;
+ return NULL;
+ }
+
+ template<typename TDataType>
+ bool readProperty(TDataType& outType)
+ {
+ const char* value = getCurrentValue();
+ if ( value && *value )
+ {
+ stringToType( value, outType );
+ return true;
+ }
+ return false;
+ }
+
+ template<typename TDataType>
+ bool readExtendedIndexProperty(TDataType& outType)
+ {
+ const char* value = mReader.getCurrentItemValue();
+ if ( value && *value )
+ {
+ stringToType( value, outType );
+ return true;
+ }
+ return false;
+ }
+
+
+ template<typename TRefType>
+ bool readReference(TRefType*& outRef)
+ {
+ return physx::Sn::readReference<TRefType>( mReader, mCollection, topName(), outRef );
+ }
+
+ inline bool readProperty(const char*& outProp )
+ {
+ outProp = "";
+ const char* value = getCurrentValue();
+ if ( value && *value && mArgs.stringTable )
+ {
+ outProp = mArgs.stringTable->allocateStr( value );
+ return true;
+ }
+ return false;
+ }
+
+ inline bool readProperty(PxConvexMesh*& outProp )
+ {
+ return readReference<PxConvexMesh>( outProp );
+ }
+
+ inline bool readProperty(PxTriangleMesh*& outProp )
+ {
+ return readReference<PxTriangleMesh>( outProp );
+ }
+ inline bool readProperty(PxBVH33TriangleMesh*& outProp )
+ {
+ return readReference<PxBVH33TriangleMesh>( outProp );
+ }
+ inline bool readProperty(PxBVH34TriangleMesh*& outProp )
+ {
+ return readReference<PxBVH34TriangleMesh>( outProp );
+ }
+
+ inline bool readProperty(PxHeightField*& outProp )
+ {
+ return readReference<PxHeightField>( outProp );
+ }
+
+ inline bool readProperty( PxRigidActor *& outProp )
+ {
+ return readReference<PxRigidActor>( outProp );
+ }
+
+ template<typename TAccessorType>
+ void simpleProperty( PxU32 /*key*/, TAccessorType& inProp )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ TPropertyType value;
+ if ( readProperty( value ) )
+ inProp.set( mObj, value );
+ }
+
+ template<typename TAccessorType>
+ void enumProperty( PxU32 /*key*/, TAccessorType& inProp, const PxU32ToName* inConversions )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ const char* strVal = getCurrentValue();
+ if ( strVal && *strVal )
+ {
+ TPropertyType pval;
+ stringToEnumType( strVal, pval, inConversions );
+ inProp.set( mObj, pval );
+ }
+ }
+
+ template<typename TAccessorType>
+ void flagsProperty( PxU32 /*key*/, const TAccessorType& inProp, const PxU32ToName* inConversions )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ typedef typename TPropertyType::InternalType TInternalType;
+
+ const char* strVal = getCurrentValue();
+ if ( strVal && *strVal )
+ {
+ PxU32 tempValue = 0;
+ stringToFlagsType( strVal, mAllocator, tempValue, inConversions );
+ inProp.set( mObj, TPropertyType(TInternalType( tempValue )));
+ }
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void complexProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ if ( gotoTopName() )
+ {
+ TPropertyType propVal = inProp.get( mObj );
+ readComplexObj( *this, &propVal, inInfo );
+ inProp.set( mObj, propVal );
+ }
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void bufferCollectionProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ Ps::InlineArray<TPropertyType,5> theData;
+
+ this->pushCurrentContext();
+ if ( this->gotoTopName() )
+ {
+ for ( bool success = this->gotoFirstChild(); success;
+ success = this->gotoNextSibling() )
+ {
+ TPropertyType propVal;
+ readComplexObj( *this, &propVal, inInfo );
+ theData.pushBack(propVal);
+ }
+ }
+ this->popCurrentContext();
+
+ inProp.set( mObj, theData.begin(), theData.size() );
+
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void extendedIndexedProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+
+ this->pushCurrentContext();
+ if ( this->gotoTopName() )
+ {
+ PxU32 index = 0;
+ for ( bool success = this->gotoFirstChild(); success;
+ success = this->gotoNextSibling() )
+ {
+ TPropertyType propVal;
+ readComplexObj( *this, &propVal, inInfo );
+ inProp.set(mObj, index, propVal);
+ ++index;
+ }
+ }
+ this->popCurrentContext();
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void PxFixedSizeLookupTableProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ const_cast<TAccessorType&>(inProp).clear( mObj );
+
+ this->pushCurrentContext();
+ if ( this->gotoTopName() )
+ {
+ for ( bool success = this->gotoFirstChild(); success;
+ success = this->gotoNextSibling() )
+ {
+ TPropertyType propXVal;
+ readComplexObj( *this, &propXVal, inInfo );
+
+ if(this->gotoNextSibling())
+ {
+ TPropertyType propYVal;
+ readComplexObj( *this, &propYVal, inInfo );
+ const_cast<TAccessorType&>(inProp).addPair(mObj, propXVal, propYVal);
+ }
+ }
+ }
+ this->popCurrentContext();
+ }
+
+ void handleShapes( const PxRigidActorShapeCollection& inProp )
+ {
+ physx::Sn::readShapesProperty( *this, mObj, &inProp );
+ }
+ };
+
+ template<typename TObjType>
+ struct RepXVisitorReader : public RepXVisitorReaderBase<TObjType>
+ {
+ RepXVisitorReader( TReaderNameStack& names, PxProfileArray<PxU32>& contexts, const PxRepXInstantiationArgs& args, XmlReader& reader, TObjType* obj
+ , XmlMemoryAllocator& alloc, PxCollection& collection, bool& ret)
+ : RepXVisitorReaderBase<TObjType>( names, contexts, args, reader, obj, alloc, collection, ret)
+ {
+ }
+ RepXVisitorReader( const RepXVisitorReader<TObjType>& other )
+ : RepXVisitorReaderBase<TObjType>( other )
+ {
+ }
+ };
+
+ // Specialized template to load dynamic rigid, to determine the kinematic state first
+ template<>
+ struct RepXVisitorReader<PxRigidDynamic> : public RepXVisitorReaderBase<PxRigidDynamic>
+ {
+ RepXVisitorReader( TReaderNameStack& names, PxProfileArray<PxU32>& contexts, const PxRepXInstantiationArgs& args, XmlReader& reader, PxRigidDynamic* obj
+ , XmlMemoryAllocator& alloc, PxCollection& collection, bool& ret)
+ : RepXVisitorReaderBase<PxRigidDynamic>( names, contexts, args, reader, obj, alloc, collection, ret)
+ {
+ }
+ RepXVisitorReader( const RepXVisitorReader<PxRigidDynamic>& other )
+ : RepXVisitorReaderBase<PxRigidDynamic>( other )
+ {
+ }
+
+ void handleShapes( const PxRigidActorShapeCollection& inProp )
+ {
+ // Need to read the parental actor to check if actor is kinematic
+ // in that case we need to apply the kinematic flag before a shape is set
+ XmlReaderWriter* parentReader = static_cast<XmlReaderWriter*>(mReader.getParentReader());
+ if(mObj)
+ {
+ const char* value;
+ if (parentReader->read( "RigidBodyFlags", value ))
+ {
+ if(strstr(value, "eKINEMATIC"))
+ {
+ mObj->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
+ }
+ }
+ }
+ physx::Sn::readShapesProperty( *this, mObj, &inProp );
+ parentReader->release();
+ }
+
+
+ template<typename TAccessorType>
+ void simpleProperty( PxU32 /*key*/, TAccessorType& inProp )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ TPropertyType value;
+ if (readProperty(value))
+ {
+ // If the rigid body is kinematic, we cannot set the LinearVelocity or AngularVelocity
+ const bool kinematic = (mObj->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC);
+ if(kinematic && (inProp.mProperty.mKey == PxPropertyInfoName::PxRigidBody_LinearVelocity || inProp.mProperty.mKey == PxPropertyInfoName::PxRigidBody_AngularVelocity))
+ return;
+
+ inProp.set(mObj, value );
+ }
+ }
+ private:
+ RepXVisitorReader<PxRigidDynamic>& operator=(const RepXVisitorReader<PxRigidDynamic>&);
+ };
+
+ template<>
+ struct RepXVisitorReader<PxShape> : public RepXVisitorReaderBase<PxShape>
+ {
+ RepXVisitorReader( TReaderNameStack& names, PxProfileArray<PxU32>& contexts, const PxRepXInstantiationArgs& args, XmlReader& reader, PxShape* obj
+ , XmlMemoryAllocator& alloc, PxCollection& collection, bool& ret )
+ : RepXVisitorReaderBase<PxShape>( names, contexts, args, reader, obj, alloc, collection, ret )
+ {
+ }
+ RepXVisitorReader( const RepXVisitorReader<PxShape>& other )
+ : RepXVisitorReaderBase<PxShape>( other )
+ {
+ }
+ void handleShapeMaterials( const PxShapeMaterialsProperty& ) //these were handled during construction.
+ {
+ }
+ void handleGeometryProperty( const PxShapeGeometryProperty& )
+ {
+ }
+ private:
+ RepXVisitorReader<PxShape>& operator=(const RepXVisitorReader<PxShape>&);
+ };
+
+ template<>
+ struct RepXVisitorReader<PxArticulationLink> : public RepXVisitorReaderBase<PxArticulationLink>
+ {
+ RepXVisitorReader( TReaderNameStack& names, PxProfileArray<PxU32>& contexts, const PxRepXInstantiationArgs& args, XmlReader& reader, PxArticulationLink* obj
+ , XmlMemoryAllocator& alloc, PxCollection& collection, bool& ret )
+ : RepXVisitorReaderBase<PxArticulationLink>( names, contexts, args, reader, obj, alloc, collection, ret )
+ {
+ }
+ RepXVisitorReader( const RepXVisitorReader<PxArticulationLink>& other )
+ : RepXVisitorReaderBase<PxArticulationLink>( other )
+ {
+ }
+ void handleIncomingJoint( const TIncomingJointPropType& prop )
+ {
+ pushName( "Joint" );
+ if ( gotoTopName() )
+ {
+ PxArticulationJoint* theJoint( prop.get( mObj ) );
+ readComplexObj( *this, theJoint );
+
+ //Add joint to PxCollection, since PxArticulation requires PxArticulationLink and joint.
+ mCollection.add( *theJoint );
+ }
+ popName();
+ }
+ private:
+ RepXVisitorReader<PxArticulationLink>& operator=(const RepXVisitorReader<PxArticulationLink>&);
+ };
+
+ inline void readProperty( RepXVisitorReaderBase<PxArticulation>& inSerializer, PxArticulation* inObj, const PxArticulationLinkCollectionProp& /*inProp*/)
+ {
+ PxProfileAllocatorWrapper theWrapper( inSerializer.mAllocator.getAllocator() );
+ PxCollection& collection( inSerializer.mCollection );
+
+ TArticulationLinkLinkMap linkRemapMap( theWrapper );
+ inSerializer.pushCurrentContext();
+ if( inSerializer.gotoTopName() )
+ {
+ for ( bool links = inSerializer.gotoFirstChild();
+ links != false;
+ links = inSerializer.gotoNextSibling() )
+ {
+ //Need enough information to create the link...
+ PxSerialObjectId theParentPtr = 0;
+ const PxArticulationLink* theParentLink = NULL;
+ if ( inSerializer.mReader.read( "Parent", theParentPtr ) )
+ {
+ const TArticulationLinkLinkMap::Entry* theRemappedParent( linkRemapMap.find( theParentPtr ) );
+ //If we have a valid at write time, we had better have a valid parent at read time.
+ PX_ASSERT( theRemappedParent );
+ theParentLink = theRemappedParent->second;
+ }
+ PxArticulationLink* newLink = inObj->createLink( const_cast<PxArticulationLink*>( theParentLink ), PxTransform(PxIdentity) );
+ PxSerialObjectId theIdPtr = 0;
+ inSerializer.mReader.read( "Id", theIdPtr );
+
+ linkRemapMap.insert( theIdPtr, newLink );
+ readComplexObj( inSerializer, newLink );
+
+ //Add link to PxCollection, since PxArticulation requires PxArticulationLink and joint.
+ collection.add( *newLink, theIdPtr );
+ }
+ }
+ inSerializer.popCurrentContext();
+ }
+
+ template<>
+ struct RepXVisitorReader<PxArticulation> : public RepXVisitorReaderBase<PxArticulation>
+ {
+ RepXVisitorReader( TReaderNameStack& names, PxProfileArray<PxU32>& contexts, const PxRepXInstantiationArgs& args, XmlReader& reader, PxArticulation* obj
+ , XmlMemoryAllocator& alloc, PxCollection& collection, bool& ret)
+ : RepXVisitorReaderBase<PxArticulation>( names, contexts, args, reader, obj, alloc, collection, ret)
+ {
+ }
+ RepXVisitorReader( const RepXVisitorReader<PxArticulation>& other )
+ : RepXVisitorReaderBase<PxArticulation>( other )
+ {
+ }
+
+ void handleArticulationLinks( const PxArticulationLinkCollectionProp& inProp )
+ {
+ physx::Sn::readProperty( *this, mObj, inProp );
+ }
+ };
+
+ template<typename TObjType, typename TInfoType>
+ inline bool readAllProperties( PxRepXInstantiationArgs args, TReaderNameStack& names, PxProfileArray<PxU32>& contexts, XmlReader& reader, TObjType* obj, XmlMemoryAllocator& alloc, PxCollection& collection, TInfoType& info )
+ {
+ bool hadError = false;
+ RepXVisitorReader<TObjType> theReader( names, contexts, args, reader, obj, alloc, collection, hadError);
+ RepXPropertyFilter<RepXVisitorReader<TObjType> > theOp( theReader );
+ info.visitBaseProperties( theOp );
+ info.visitInstanceProperties( theOp );
+ return !hadError;
+ }
+
+
+ template<typename TObjType>
+ inline bool readAllProperties( PxRepXInstantiationArgs args, XmlReader& reader, TObjType* obj, XmlMemoryAllocator& alloc, PxCollection& collection )
+ {
+ PxProfileAllocatorWrapper wrapper( alloc.getAllocator() );
+ TReaderNameStack names( wrapper );
+ PxProfileArray<PxU32> contexts( wrapper );
+ PxClassInfoTraits<TObjType> info;
+ return readAllProperties( args, names, contexts, reader, obj, alloc, collection, info.Info );
+ }
+
+ template<typename TObjType, typename TReaderType, typename TInfoType>
+ inline void readComplexObj( TReaderType& oldVisitor, TObjType* inObj, TInfoType& info)
+ {
+ if(!readAllProperties( oldVisitor.mArgs, oldVisitor.mNames, oldVisitor.mContexts, oldVisitor.mReader, inObj, oldVisitor.mAllocator, oldVisitor.mCollection, info ))
+ oldVisitor.mHadError = true;
+ }
+
+ template<typename TObjType, typename TReaderType, typename TInfoType>
+ inline void readComplexObj( TReaderType& oldVisitor, TObjType* inObj, const TInfoType& info)
+ {
+ if(!readAllProperties( oldVisitor.mArgs, oldVisitor.mNames, oldVisitor.mContexts, oldVisitor.mReader, inObj, oldVisitor.mAllocator, oldVisitor.mCollection, info ))
+ oldVisitor.mHadError = true;
+ }
+
+ template<typename TObjType, typename TReaderType>
+ inline void readComplexObj( TReaderType& oldVisitor, TObjType* inObj, const PxUnknownClassInfo& /*info*/)
+ {
+ const char* value = oldVisitor.mReader.getCurrentItemValue();
+ if ( value && *value )
+ {
+ stringToType( value, *inObj );
+ return;
+ }
+ oldVisitor.mHadError = true;
+ }
+
+ template<typename TObjType, typename TReaderType>
+ inline void readComplexObj( TReaderType& oldVisitor, TObjType* inObj)
+ {
+ PxClassInfoTraits<TObjType> info;
+ if(!readAllProperties( oldVisitor.mArgs, oldVisitor.mNames, oldVisitor.mContexts, oldVisitor.mReader, inObj, oldVisitor.mAllocator, oldVisitor.mCollection, info.Info ))
+ oldVisitor.mHadError = true;
+ }
+
+} }
+
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorWriter.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorWriter.h
new file mode 100644
index 00000000..76bf66cd
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlVisitorWriter.h
@@ -0,0 +1,765 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_VISITOR_WRITER_H
+#define PX_XML_VISITOR_WRITER_H
+
+#include "PsInlineArray.h"
+#include "CmPhysXCommon.h"
+#include "RepXMetaDataPropertyVisitor.h"
+#include "SnPxStreamOperators.h"
+#include "SnXmlMemoryPoolStreams.h"
+#include "SnXmlWriter.h"
+#include "SnXmlImpl.h"
+#include "PsFoundation.h"
+
+namespace physx { namespace Sn {
+
+ template<typename TDataType>
+ inline void writeReference( XmlWriter& writer, PxCollection& inCollection, const char* inPropName, const TDataType* inDatatype )
+ {
+ const PxBase* s = static_cast<const PxBase*>( inDatatype ) ;
+ if( inDatatype && !inCollection.contains( *const_cast<PxBase*>(s) ))
+ {
+ Ps::getFoundation().error(PxErrorCode::eINTERNAL_ERROR, __FILE__, __LINE__,
+ "PxSerialization::serializeCollectionToXml: Reference \"%s\" could not be resolved.", inPropName);
+ }
+
+ PxSerialObjectId theId = 0;
+ if( s )
+ {
+ theId = inCollection.getId( *s );
+ if( theId == 0 )
+ theId = PX_PROFILE_POINTER_TO_U64( inDatatype );
+ }
+
+ writer.write( inPropName, PxCreateRepXObject( inDatatype, theId ) );
+ }
+
+ inline void writeProperty( XmlWriter& inWriter, MemoryBuffer& inBuffer, const char* inProp )
+ {
+ PxU8 data = 0;
+ inBuffer.write( &data, sizeof(PxU8) );
+ inWriter.write( inProp, reinterpret_cast<const char*>( inBuffer.mBuffer ) );
+ inBuffer.clear();
+ }
+
+ template<typename TDataType>
+ inline void writeProperty( XmlWriter& inWriter, PxCollection&, MemoryBuffer& inBuffer, const char* inPropName, TDataType inValue )
+ {
+ inBuffer << inValue;
+ writeProperty( inWriter, inBuffer, inPropName );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, const PxConvexMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxConvexMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+#ifdef REMOVED
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, const PxTriangleMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxTriangleMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+#endif
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, const PxBVH33TriangleMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxBVH33TriangleMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, const PxBVH34TriangleMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxBVH34TriangleMesh* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, const PxHeightField* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxHeightField* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, const PxRigidActor* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxArticulation* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeProperty( XmlWriter& writer, PxCollection& inCollection, MemoryBuffer& /*inBuffer*/, const char* inPropName, PxRigidActor* inDatatype )
+ {
+ writeReference( writer, inCollection, inPropName, inDatatype );
+ }
+
+ inline void writeFlagsProperty( XmlWriter& inWriter, MemoryBuffer& tempBuf, const char* inPropName, PxU32 inFlags, const PxU32ToName* inTable )
+ {
+ if ( inTable )
+ {
+ PxU32 flagValue( inFlags );
+ if ( flagValue )
+ {
+ for ( PxU32 idx =0; inTable[idx].mName != NULL; ++idx )
+ {
+ if ( (inTable[idx].mValue & flagValue) == inTable[idx].mValue )
+ {
+ if ( tempBuf.mWriteOffset != 0 )
+ tempBuf << "|";
+ tempBuf << inTable[idx].mName;
+ }
+ }
+ writeProperty( inWriter, tempBuf, inPropName );
+ }
+ }
+ }
+
+ inline void writeFlagsBuffer( MemoryBuffer& tempBuf, PxU32 flagValue, const PxU32ToName* inTable )
+ {
+ PX_ASSERT(inTable);
+ bool added = false;
+
+ if ( flagValue )
+ {
+ for ( PxU32 item =0; inTable[item].mName != NULL; ++item )
+ {
+ if ( (inTable[item].mValue & flagValue) != 0 )
+ {
+ if ( added )
+ tempBuf << "|";
+ tempBuf << inTable[item].mName;
+ added = true;
+ }
+ }
+ }
+ }
+
+ inline void writePxVec3( PxOutputStream& inStream, const PxVec3& inVec ) { inStream << inVec; }
+
+
+ template<typename TDataType>
+ inline const TDataType& PtrAccess( const TDataType* inPtr, PxU32 inIndex )
+ {
+ return inPtr[inIndex];
+ }
+
+ template<typename TDataType>
+ inline void BasicDatatypeWrite( PxOutputStream& inStream, const TDataType& item ) { inStream << item; }
+
+ template<typename TObjType, typename TAccessOperator, typename TWriteOperator>
+ inline void writeBuffer( XmlWriter& inWriter, MemoryBuffer& inTempBuffer
+ , PxU32 inObjPerLine, const TObjType* inObjType, TAccessOperator inAccessOperator
+ , PxU32 inBufSize, const char* inPropName, TWriteOperator inOperator )
+ {
+ if ( inBufSize && inObjType )
+ {
+ for ( PxU32 idx = 0; idx < inBufSize; ++idx )
+ {
+ if ( idx && ( idx % inObjPerLine == 0 ) )
+ inTempBuffer << "\n\t\t\t";
+ else
+ inTempBuffer << " ";
+ inOperator( inTempBuffer, inAccessOperator( inObjType, idx ) );
+ }
+ writeProperty( inWriter, inTempBuffer, inPropName );
+ }
+ }
+
+ template<typename TDataType, typename TAccessOperator, typename TWriteOperator>
+ inline void writeStrideBuffer( XmlWriter& inWriter, MemoryBuffer& inTempBuffer
+ , PxU32 inObjPerLine, PxStrideIterator<const TDataType>& inData, TAccessOperator inAccessOperator
+ , PxU32 inBufSize, const char* inPropName, PxU32 /*inStride*/, TWriteOperator inOperator )
+ {
+ if ( inBufSize && &inData[0])
+ {
+ for ( PxU32 idx = 0; idx < inBufSize; ++idx )
+ {
+ if ( idx && ( idx % inObjPerLine == 0 ) )
+ inTempBuffer << "\n\t\t\t";
+ else
+ inTempBuffer << " ";
+
+ inOperator( inTempBuffer, inAccessOperator( &inData[idx], 0 ) );
+ }
+ writeProperty( inWriter, inTempBuffer, inPropName );
+ }
+ }
+
+
+ template<typename TDataType, typename TAccessOperator>
+ inline void writeStrideFlags( XmlWriter& inWriter, MemoryBuffer& inTempBuffer
+ , PxU32 inObjPerLine, PxStrideIterator<const TDataType>& inData, TAccessOperator /*inAccessOperator*/
+ , PxU32 inBufSize, const char* inPropName, const PxU32ToName* inTable)
+ {
+ if ( inBufSize && &inData[0])
+ {
+ for ( PxU32 idx = 0; idx < inBufSize; ++idx )
+ {
+ writeFlagsBuffer(inTempBuffer, inData[idx], inTable);
+
+ if ( idx && ( idx % inObjPerLine == 0 ) )
+ inTempBuffer << "\n\t\t\t";
+ else
+ inTempBuffer << " ";
+ }
+ writeProperty( inWriter, inTempBuffer, inPropName );
+ }
+ }
+
+ template<typename TDataType, typename TWriteOperator>
+ inline void writeBuffer( XmlWriter& inWriter, MemoryBuffer& inTempBuffer
+ , PxU32 inObjPerLine, const TDataType* inBuffer
+ , PxU32 inBufSize, const char* inPropName, TWriteOperator inOperator )
+ {
+ writeBuffer( inWriter, inTempBuffer, inObjPerLine, inBuffer, PtrAccess<TDataType>, inBufSize, inPropName, inOperator );
+ }
+
+ template<typename TEnumType>
+ inline void writeEnumProperty( XmlWriter& inWriter, const char* inPropName, TEnumType inEnumValue, const PxU32ToName* inConversions )
+ {
+ PxU32 theValue = static_cast<PxU32>( inEnumValue );
+ for ( const PxU32ToName* conv = inConversions; conv->mName != NULL; ++conv )
+ if ( conv->mValue == theValue ) inWriter.write( inPropName, conv->mName );
+ }
+
+
+
+ template<typename TObjType, typename TWriterType, typename TInfoType>
+ inline void handleComplexObj( TWriterType& oldVisitor, const TObjType* inObj, TInfoType& info);
+
+ template<typename TCollectionType, typename TVisitor, typename TPropType, typename TInfoType >
+ void handleComplexCollection( TVisitor& visitor, const TPropType& inProp, const char* childName, TInfoType& inInfo )
+ {
+ PxU32 count( inProp.size( visitor.mObj ) );
+ if ( count )
+ {
+ Ps::InlineArray<TCollectionType*,5> theData;
+ theData.resize( count );
+ inProp.get( visitor.mObj, theData.begin(), count );
+ for( PxU32 idx =0; idx < count; ++idx )
+ {
+ visitor.pushName( childName );
+ handleComplexObj( visitor, theData[idx], inInfo );
+ visitor.popName();
+ }
+ }
+ }
+
+ template<typename TCollectionType, typename TVisitor, typename TPropType, typename TInfoType >
+ void handleBufferCollection( TVisitor& visitor, const TPropType& inProp, const char* childName, TInfoType& inInfo )
+ {
+ PxU32 count( inProp.size( visitor.mObj ) );
+ if ( count )
+ {
+ Ps::InlineArray<TCollectionType*,5> theData;
+ theData.resize( count );
+ inProp.get( visitor.mObj, theData.begin());
+
+ for( PxU32 idx =0; idx < count; ++idx )
+ {
+ visitor.pushName( childName );
+ handleComplexObj( visitor, theData[idx], inInfo );
+ visitor.popName();
+ }
+ }
+ }
+
+ template<typename TVisitor>
+ void handleShapes( TVisitor& visitor, const PxRigidActorShapeCollection& inProp )
+ {
+ PxShapeGeneratedInfo theInfo;
+
+ PxU32 count( inProp.size( visitor.mObj ) );
+ if ( count )
+ {
+ Ps::InlineArray<PxShape*,5> theData;
+ theData.resize( count );
+ inProp.get( visitor.mObj, theData.begin(), count );
+ for( PxU32 idx = 0; idx < count; ++idx )
+ {
+ const PxShape* shape = theData[idx];
+ visitor.pushName( "PxShape" );
+
+ if( !shape->isExclusive() )
+ {
+ writeReference( visitor.mWriter, visitor.mCollection, "PxShapeRef", shape );
+ }
+ else
+ {
+ handleComplexObj( visitor, shape, theInfo );
+ }
+ visitor.popName();
+ }
+ }
+ }
+
+ template<typename TVisitor>
+ void handleShapeMaterials( TVisitor& visitor, const PxShapeMaterialsProperty& inProp )
+ {
+ PxU32 count( inProp.size( visitor.mObj ) );
+ if ( count )
+ {
+ Ps::InlineArray<PxMaterial*,5> theData;
+ theData.resize( count );
+ inProp.get( visitor.mObj, theData.begin(), count );
+ visitor.pushName( "PxMaterialRef" );
+
+ for( PxU32 idx =0; idx < count; ++idx )
+ writeReference( visitor.mWriter, visitor.mCollection, "PxMaterialRef", theData[idx] );
+ visitor.popName();
+ }
+ }
+
+ template<typename TObjType>
+ struct RepXVisitorWriterBase
+ {
+ TNameStack& mNameStack;
+ XmlWriter& mWriter;
+ const TObjType* mObj;
+ MemoryBuffer& mTempBuffer;
+ PxCollection& mCollection;
+
+ RepXVisitorWriterBase( TNameStack& ns, XmlWriter& writer, const TObjType* obj, MemoryBuffer& buf, PxCollection& collection )
+ : mNameStack( ns )
+ , mWriter( writer )
+ , mObj( obj )
+ , mTempBuffer( buf )
+ , mCollection( collection )
+ {
+ }
+
+ RepXVisitorWriterBase( const RepXVisitorWriterBase<TObjType>& other )
+ : mNameStack( other.mNameStack )
+ , mWriter( other.mWriter )
+ , mObj( other.mObj )
+ , mTempBuffer( other.mTempBuffer )
+ , mCollection( other.mCollection )
+ {
+ }
+
+ RepXVisitorWriterBase& operator=( const RepXVisitorWriterBase& ){ PX_ASSERT( false ); return *this; }
+
+ void gotoTopName()
+ {
+ if ( mNameStack.size() && mNameStack.back().mOpen == false )
+ {
+ mWriter.addAndGotoChild( mNameStack.back().mName );
+ mNameStack.back().mOpen = true;
+ }
+ }
+
+ void pushName( const char* inName )
+ {
+ gotoTopName();
+ mNameStack.pushBack( inName );
+ }
+
+ void pushBracketedName( const char* inName ) { pushName( inName ); }
+ void popName()
+ {
+ if ( mNameStack.size() )
+ {
+ if ( mNameStack.back().mOpen )
+ mWriter.leaveChild();
+ mNameStack.popBack();
+ }
+ }
+
+ const char* topName() const
+ {
+ if ( mNameStack.size() ) return mNameStack.back().mName;
+ PX_ASSERT( false );
+ return "bad__repx__name";
+ }
+
+ template<typename TAccessorType>
+ void simpleProperty( PxU32 /*key*/, TAccessorType& inProp )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ TPropertyType propVal = inProp.get( mObj );
+ writeProperty( mWriter, mCollection, mTempBuffer, topName(), propVal );
+ }
+
+ template<typename TAccessorType>
+ void enumProperty( PxU32 /*key*/, TAccessorType& inProp, const PxU32ToName* inConversions )
+ {
+ writeEnumProperty( mWriter, topName(), inProp.get( mObj ), inConversions );
+ }
+
+ template<typename TAccessorType>
+ void flagsProperty( PxU32 /*key*/, const TAccessorType& inProp, const PxU32ToName* inConversions )
+ {
+ writeFlagsProperty( mWriter, mTempBuffer, topName(), inProp.get( mObj ), inConversions );
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void complexProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ TPropertyType propVal = inProp.get( mObj );
+ handleComplexObj( *this, &propVal, inInfo );
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void bufferCollectionProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+
+ PxU32 count( inProp.size( mObj ) );
+ Ps::InlineArray<TPropertyType,5> theData;
+ theData.resize( count );
+
+ PxClassInfoTraits<TInfoType> theTraits;
+ PX_UNUSED(theTraits);
+ PxU32 numItems = inProp.get( mObj, theData.begin(), count );
+ PX_ASSERT( numItems == count );
+ for( PxU32 idx =0; idx < numItems; ++idx )
+ {
+ pushName( inProp.name() );
+ handleComplexObj( *this, &theData[idx], inInfo );
+ popName();
+ }
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void extendedIndexedProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& /*inInfo */)
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+
+ PxU32 count( inProp.size( mObj ) );
+ Ps::InlineArray<TPropertyType,5> theData;
+ theData.resize( count );
+
+ for(PxU32 i = 0; i < count; ++i)
+ {
+ char buffer[32] = { 0 };
+ sprintf( buffer, "id_%u", i );
+ pushName( buffer );
+
+ TPropertyType propVal = inProp.get( mObj, i );
+ TInfoType& infoType = PxClassInfoTraits<TPropertyType>().Info;
+ handleComplexObj(*this, &propVal, infoType);
+ popName();
+ }
+ }
+
+ template<typename TAccessorType, typename TInfoType>
+ void PxFixedSizeLookupTableProperty( PxU32* /*key*/, TAccessorType& inProp, TInfoType& /*inInfo */)
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ PxU32 count( inProp.size( mObj ) );
+
+ PxU32 index = 0;
+ for(PxU32 i = 0; i < count; ++i)
+ {
+ char buffer[32] = { 0 };
+ sprintf( buffer, "id_%u", index++ );
+ pushName( buffer );
+ TPropertyType propVal = inProp.getX( mObj , i);
+ writeProperty( mWriter, mCollection, mTempBuffer, topName(), propVal );
+ popName();
+
+ sprintf( buffer, "id_%u", index++ );
+ pushName( buffer );
+ propVal = inProp.getY( mObj , i);
+ writeProperty( mWriter, mCollection, mTempBuffer, topName(), propVal );
+ popName();
+ }
+ }
+
+
+ void handleShapes( const PxRigidActorShapeCollection& inProp )
+ {
+ physx::Sn::handleShapes( *this, inProp );
+ }
+
+ void handleShapeMaterials( const PxShapeMaterialsProperty& inProp )
+ {
+ physx::Sn::handleShapeMaterials( *this, inProp );
+ }
+ };
+
+ template<typename TObjType>
+ struct RepXVisitorWriter : RepXVisitorWriterBase<TObjType>
+ {
+ RepXVisitorWriter( TNameStack& ns, XmlWriter& writer, const TObjType* obj, MemoryBuffer& buf, PxCollection& collection )
+ : RepXVisitorWriterBase<TObjType>( ns, writer, obj, buf, collection )
+ {
+ }
+
+ RepXVisitorWriter( const RepXVisitorWriter<TObjType>& other )
+ : RepXVisitorWriterBase<TObjType>( other )
+ {
+ }
+ };
+
+ template<>
+ struct RepXVisitorWriter<PxArticulationLink> : RepXVisitorWriterBase<PxArticulationLink>
+ {
+ RepXVisitorWriter( TNameStack& ns, XmlWriter& writer, const PxArticulationLink* obj, MemoryBuffer& buf, PxCollection& collection )
+ : RepXVisitorWriterBase<PxArticulationLink>( ns, writer, obj, buf, collection )
+ {
+ }
+
+ RepXVisitorWriter( const RepXVisitorWriter<PxArticulationLink>& other )
+ : RepXVisitorWriterBase<PxArticulationLink>( other )
+ {
+ }
+
+ void handleIncomingJoint( const TIncomingJointPropType& prop )
+ {
+ const PxArticulationJoint* theJoint( prop.get( mObj ) );
+ if ( theJoint )
+ {
+ PxArticulationJointGeneratedInfo info;
+ pushName( "Joint" );
+ handleComplexObj( *this, theJoint, info );
+ popName();
+ }
+ }
+ };
+
+ typedef PxProfileHashMap< const PxSerialObjectId, const PxArticulationLink* > TArticulationLinkLinkMap;
+
+ template<>
+ struct RepXVisitorWriter<PxArticulation> : RepXVisitorWriterBase<PxArticulation>
+ {
+ TArticulationLinkLinkMap& mArticulationLinkParents;
+
+ RepXVisitorWriter( TNameStack& ns, XmlWriter& writer, const PxArticulation* inArticulation, MemoryBuffer& buf, PxCollection& collection, TArticulationLinkLinkMap* artMap = NULL )
+ : RepXVisitorWriterBase<PxArticulation>( ns, writer, inArticulation, buf, collection )
+ , mArticulationLinkParents( *artMap )
+ {
+ Ps::InlineArray<PxArticulationLink*, 64, PxProfileWrapperReflectionAllocator<PxArticulationLink*> > linkList( PxProfileWrapperReflectionAllocator<PxArticulationLink*>( buf.mManager->getWrapper() ) );
+ PxU32 numLinks = inArticulation->getNbLinks();
+ linkList.resize( numLinks );
+ inArticulation->getLinks( linkList.begin(), numLinks );
+ for ( PxU32 idx = 0; idx < numLinks; ++idx )
+ {
+ const PxArticulationLink* theLink( linkList[idx] );
+
+ Ps::InlineArray<PxArticulationLink*, 64> theChildList;
+ PxU32 numChildren = theLink->getNbChildren();
+ theChildList.resize( numChildren );
+ theLink->getChildren( theChildList.begin(), numChildren );
+ for ( PxU32 childIdx = 0; childIdx < numChildren; ++childIdx )
+ mArticulationLinkParents.insert( PX_PROFILE_POINTER_TO_U64(theChildList[childIdx]), theLink );
+ }
+ }
+
+ RepXVisitorWriter( const RepXVisitorWriter<PxArticulation>& other )
+ : RepXVisitorWriterBase<PxArticulation>( other )
+ , mArticulationLinkParents( other.mArticulationLinkParents )
+ {
+ }
+ template<typename TAccessorType, typename TInfoType>
+ void complexProperty( PxU32* /*key*/, const TAccessorType& inProp, TInfoType& inInfo )
+ {
+ typedef typename TAccessorType::prop_type TPropertyType;
+ TPropertyType propVal = inProp.get( mObj );
+ handleComplexObj( *this, &propVal, inInfo );
+ }
+
+ void writeArticulationLink( const PxArticulationLink* inLink )
+ {
+ pushName( "PxArticulationLink" );
+ gotoTopName();
+
+ const TArticulationLinkLinkMap::Entry* theParentPtr = mArticulationLinkParents.find( PX_PROFILE_POINTER_TO_U64(inLink) );
+ if ( theParentPtr != NULL )
+ writeProperty( mWriter, mCollection, mTempBuffer, "Parent", theParentPtr->second );
+ writeProperty( mWriter, mCollection, mTempBuffer, "Id", inLink );
+
+ PxArticulationLinkGeneratedInfo info;
+ handleComplexObj( *this, inLink, info );
+ popName();
+ }
+
+ void recurseAddLinkAndChildren( const PxArticulationLink* inLink, Ps::InlineArray<const PxArticulationLink*, 64>& ioLinks )
+ {
+ ioLinks.pushBack( inLink );
+ Ps::InlineArray<PxArticulationLink*, 8> theChildren;
+ PxU32 childCount( inLink->getNbChildren() );
+ theChildren.resize( childCount );
+ inLink->getChildren( theChildren.begin(), childCount );
+ for ( PxU32 idx = 0; idx < childCount; ++idx )
+ recurseAddLinkAndChildren( theChildren[idx], ioLinks );
+ }
+
+ void handleArticulationLinks( const PxArticulationLinkCollectionProp& inProp )
+ {
+ //topologically sort the links as per my discussion with Dilip because
+ //links aren't guaranteed to have the parents before the children in the
+ //overall link list and it is unlikely to be done by beta 1.
+ PxU32 count( inProp.size( mObj ) );
+ if ( count )
+ {
+ Ps::InlineArray<PxArticulationLink*, 64> theLinks;
+ theLinks.resize( count );
+ inProp.get( mObj, theLinks.begin(), count );
+
+ Ps::InlineArray<const PxArticulationLink*, 64> theSortedLinks;
+ for ( PxU32 idx = 0; idx < count; ++idx )
+ {
+ const PxArticulationLink* theLink( theLinks[idx] );
+ if ( mArticulationLinkParents.find( PX_PROFILE_POINTER_TO_U64(theLink) ) == NULL )
+ recurseAddLinkAndChildren( theLink, theSortedLinks );
+ }
+ PX_ASSERT( theSortedLinks.size() == count );
+ for ( PxU32 idx = 0; idx < count; ++idx )
+ writeArticulationLink( theSortedLinks[idx] );
+ popName();
+ }
+ }
+ private:
+ RepXVisitorWriter<PxArticulation>& operator=(const RepXVisitorWriter<PxArticulation>&);
+ };
+
+ template<>
+ struct RepXVisitorWriter<PxShape> : RepXVisitorWriterBase<PxShape>
+ {
+ RepXVisitorWriter( TNameStack& ns, XmlWriter& writer, const PxShape* obj, MemoryBuffer& buf, PxCollection& collection )
+ : RepXVisitorWriterBase<PxShape>( ns, writer, obj, buf, collection )
+ {
+ }
+
+ RepXVisitorWriter( const RepXVisitorWriter<PxShape>& other )
+ : RepXVisitorWriterBase<PxShape>( other )
+ {
+ }
+
+ template<typename GeometryType>
+ inline void writeGeometryProperty( const PxShapeGeometryProperty& inProp, const char* inTypeName )
+ {
+ pushName( "Geometry" );
+ pushName( inTypeName );
+ GeometryType theType;
+ inProp.getGeometry( mObj, theType );
+ PxClassInfoTraits<GeometryType> theTraits;
+ PxU32 count = theTraits.Info.totalPropertyCount();
+ if(count)
+ {
+ handleComplexObj( *this, &theType, theTraits.Info);
+ }
+ else
+ {
+ writeProperty(mWriter, mTempBuffer, inTypeName);
+ }
+ popName();
+ popName();
+ }
+
+ void handleGeometryProperty( const PxShapeGeometryProperty& inProp )
+ {
+ switch( mObj->getGeometryType() )
+ {
+ case PxGeometryType::eSPHERE: writeGeometryProperty<PxSphereGeometry>( inProp, "PxSphereGeometry" ); break;
+ case PxGeometryType::ePLANE: writeGeometryProperty<PxPlaneGeometry>( inProp, "PxPlaneGeometry" ); break;
+ case PxGeometryType::eCAPSULE: writeGeometryProperty<PxCapsuleGeometry>( inProp, "PxCapsuleGeometry" ); break;
+ case PxGeometryType::eBOX: writeGeometryProperty<PxBoxGeometry>( inProp, "PxBoxGeometry" ); break;
+ case PxGeometryType::eCONVEXMESH: writeGeometryProperty<PxConvexMeshGeometry>( inProp, "PxConvexMeshGeometry" ); break;
+ case PxGeometryType::eTRIANGLEMESH: writeGeometryProperty<PxTriangleMeshGeometry>( inProp, "PxTriangleMeshGeometry" ); break;
+ case PxGeometryType::eHEIGHTFIELD: writeGeometryProperty<PxHeightFieldGeometry>( inProp, "PxHeightFieldGeometry" ); break;
+ case PxGeometryType::eINVALID:
+ case PxGeometryType::eGEOMETRY_COUNT:
+ PX_ASSERT( false );
+ }
+ }
+ };
+
+ template<typename TObjType>
+ inline void writeAllProperties( TNameStack& inNameStack, const TObjType* inObj, XmlWriter& writer, MemoryBuffer& buffer, PxCollection& collection )
+ {
+ RepXVisitorWriter<TObjType> newVisitor( inNameStack, writer, inObj, buffer, collection );
+ RepXPropertyFilter<RepXVisitorWriter<TObjType> > theOp( newVisitor );
+ PxClassInfoTraits<TObjType> info;
+ info.Info.visitBaseProperties( theOp );
+ info.Info.visitInstanceProperties( theOp );
+ }
+
+ template<typename TObjType>
+ inline void writeAllProperties( TNameStack& inNameStack, TObjType* inObj, XmlWriter& writer, MemoryBuffer& buffer, PxCollection& collection )
+ {
+ RepXVisitorWriter<TObjType> newVisitor( inNameStack, writer, inObj, buffer, collection );
+ RepXPropertyFilter<RepXVisitorWriter<TObjType> > theOp( newVisitor );
+ PxClassInfoTraits<TObjType> info;
+ info.Info.visitBaseProperties( theOp );
+ info.Info.visitInstanceProperties( theOp );
+ }
+
+ template<typename TObjType>
+ inline void writeAllProperties( const TObjType* inObj, XmlWriter& writer, MemoryBuffer& buffer, PxCollection& collection )
+ {
+ TNameStack theNames( buffer.mManager->getWrapper() );
+ writeAllProperties( theNames, inObj, writer, buffer, collection );
+ }
+
+ template<typename TObjType, typename TWriterType, typename TInfoType>
+ inline void handleComplexObj( TWriterType& oldVisitor, const TObjType* inObj, const TInfoType& /*info*/)
+ {
+ writeAllProperties( oldVisitor.mNameStack, inObj, oldVisitor.mWriter, oldVisitor.mTempBuffer, oldVisitor.mCollection );
+ }
+
+ template<typename TObjType, typename TWriterType, typename TInfoType>
+ inline void handleComplexObj( TWriterType& oldVisitor, const TObjType* inObj, TInfoType& /*info*/)
+ {
+ writeAllProperties( oldVisitor.mNameStack, inObj, oldVisitor.mWriter, oldVisitor.mTempBuffer, oldVisitor.mCollection );
+ }
+
+ template<typename TObjType, typename TWriterType>
+ inline void handleComplexObj( TWriterType& oldVisitor, const TObjType* inObj, const PxUnknownClassInfo& /*info*/)
+ {
+ writeProperty( oldVisitor.mWriter, oldVisitor.mCollection, oldVisitor.mTempBuffer, oldVisitor.topName(), *inObj );
+ }
+
+} }
+#endif
diff --git a/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlWriter.h b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlWriter.h
new file mode 100644
index 00000000..afea8aa0
--- /dev/null
+++ b/PhysX_3.4/Source/PhysXExtensions/src/serialization/Xml/SnXmlWriter.h
@@ -0,0 +1,57 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+#ifndef PX_XML_WRITER_H
+#define PX_XML_WRITER_H
+
+#include "foundation/PxSimpleTypes.h"
+
+namespace physx {
+
+ struct PxRepXObject;
+
+ /**
+ * Writer used by extensions to write elements to a file or database
+ */
+ class XmlWriter
+ {
+ protected:
+ virtual ~XmlWriter(){}
+ public:
+ /** Write a key-value pair into the current item */
+ virtual void write( const char* inName, const char* inData ) = 0;
+ /** Write an object id into the current item */
+ virtual void write( const char* inName, const PxRepXObject& inLiveObject ) = 0;
+ /** Add a child that then becomes the current context */
+ virtual void addAndGotoChild( const char* inName ) = 0;
+ /** Leave the current child */
+ virtual void leaveChild() = 0;
+ };
+}
+
+#endif