RavEngine
Loading...
Searching...
No Matches
SnXmlSerializer.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef SN_XML_SERIALIZER_H
30#define SN_XML_SERIALIZER_H
31
32#include "PxExtensionMetaDataObjects.h"
33#include "SnXmlVisitorWriter.h"
34
35namespace physx {
36
37namespace Sn {
38
39 void writeHeightFieldSample( PxOutputStream& inStream, const PxHeightFieldSample& inSample )
40 {
41 PxU32 retval = 0;
42 PxU8* writePtr( reinterpret_cast< PxU8*>( &retval ) );
43 const PxU8* inPtr( reinterpret_cast<const PxU8*>( &inSample ) );
44 if ( isBigEndian() )
45 {
46 //Height field samples are a
47 //16 bit integer followed by two bytes.
48 //right now, data is 2 1 3 4
49 //We need a 32 bit integer that
50 //when read in by a LE system is 4 3 2 1.
51 //Thus, we need a BE integer that looks like:
52 //4 3 2 1
53
54 writePtr[0] = inPtr[3];
55 writePtr[1] = inPtr[2];
56 writePtr[2] = inPtr[0];
57 writePtr[3] = inPtr[1];
58 }
59 else
60 {
61 writePtr[0] = inPtr[0];
62 writePtr[1] = inPtr[1];
63 writePtr[2] = inPtr[2];
64 writePtr[3] = inPtr[3];
65 }
66 inStream << retval;
67 }
68
69
70
71 template<typename TDataType, typename TWriteOperator>
72 inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const void* inData, PxU32 inStride, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inOperator )
73 {
74 PX_ASSERT( inStride == 0 || inStride == sizeof( TDataType ) );
75 PX_UNUSED( inStride );
76 writeBuffer( writer, tempBuffer
77 , inItemsPerLine, reinterpret_cast<const TDataType*>( inData )
78 , inCount, inPropName, inOperator );
79 }
80
81 template<typename TDataType, typename TWriteOperator>
82 inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const PxStridedData& inData, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inOperator )
83 {
84 writeStridedBufferProperty<TDataType>( writer, tempBuffer, inPropName, inData.data, inData.stride, inCount, inItemsPerLine, inOperator );
85 }
86
87 template<typename TDataType, typename TWriteOperator>
88 inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const PxTypedStridedData<TDataType>& inData, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inOperator )
89 {
90 writeStridedBufferProperty<TDataType>( writer, tempBuffer, inPropName, inData.data, inData.stride, inCount, inItemsPerLine, inOperator );
91 }
92
93 template<typename TDataType, typename TWriteOperator>
94 inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, const PxBoundedData& inData, PxU32 inItemsPerLine, TWriteOperator inWriteOperator )
95 {
96 writeStridedBufferProperty<TDataType>( writer, tempBuffer, inPropName, inData, inData.count, inItemsPerLine, inWriteOperator );
97 }
98
99 template<typename TDataType, typename TWriteOperator>
100 inline void writeStridedBufferProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, PxStrideIterator<const TDataType>& inData, PxU32 inCount, PxU32 inItemsPerLine, TWriteOperator inWriteOperator )
101 {
102 writeStrideBuffer<TDataType>(writer, tempBuffer
103 , inItemsPerLine, inData, PtrAccess<TDataType>
104 , inCount, inPropName, inData.stride(), inWriteOperator );
105 }
106
107 template<typename TDataType>
108 inline void writeStridedFlagsProperty( XmlWriter& writer, MemoryBuffer& tempBuffer, const char* inPropName, PxStrideIterator<const TDataType>& inData, PxU32 inCount, PxU32 inItemsPerLine, const PxU32ToName* inTable )
109 {
110 writeStrideFlags<TDataType>(writer, tempBuffer
111 , inItemsPerLine, inData, PtrAccess<TDataType>
112 , inCount, inPropName, inTable );
113 }
114
115}
116}
117#endif
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39