RavEngine
Loading...
Searching...
No Matches
PxPvdObjectModelInternalTypes.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
27#ifndef PX_PVD_OBJECT_MODEL_INTERNAL_TYPES_H
28#define PX_PVD_OBJECT_MODEL_INTERNAL_TYPES_H
29
30#include "foundation/PxMemory.h"
31#include "PxPvdObjectModelBaseTypes.h"
32#include "foundation/PxArray.h"
33#include "PxPvdFoundation.h"
34
35namespace physx
36{
37namespace pvdsdk
38{
39
41{
42 enum Enum
43 {
44 None = 0,
45#define DECLARE_INTERNAL_PVD_TYPE(type) type,
46#include "PxPvdObjectModelInternalTypeDefs.h"
47 Last
48#undef DECLARE_INTERNAL_PVD_TYPE
49 };
50};
51
52PX_COMPILE_TIME_ASSERT(uint32_t(PvdInternalType::Last) <= uint32_t(PvdBaseType::InternalStop));
53
54template <typename T>
56{
57 bool compile_error;
58};
59template <PvdInternalType::Enum>
61{
62 bool compile_error;
63};
64
65#define DECLARE_INTERNAL_PVD_TYPE(type) \
66 template <> \
67 struct DataTypeToPvdTypeMap<type> \
68 { \
69 enum Enum \
70 { \
71 BaseTypeEnum = PvdInternalType::type \
72 }; \
73 }; \
74 template <> \
75 struct PvdTypeToDataTypeMap<PvdInternalType::type> \
76 { \
77 typedef type TDataType; \
78 }; \
79 template <> \
80 struct PvdDataTypeToNamespacedNameMap<type> \
81 { \
82 NamespacedName Name; \
83 PvdDataTypeToNamespacedNameMap<type>() : Name("physx3_debugger_internal", #type) \
84 { \
85 } \
86 };
87#include "PxPvdObjectModelInternalTypeDefs.h"
88#undef DECLARE_INTERNAL_PVD_TYPE
89
90template <typename TDataType, typename TAlloc>
92{
93 return DataRef<TDataType>(data.begin(), data.end());
94}
95
96static inline bool safeStrEq(const DataRef<String>& lhs, const DataRef<String>& rhs)
97{
98 uint32_t count = lhs.size();
99 if(count != rhs.size())
100 return false;
101 for(uint32_t idx = 0; idx < count; ++idx)
102 if(!safeStrEq(lhs[idx], rhs[idx]))
103 return false;
104 return true;
105}
106
107static inline char* copyStr(const char* str)
108{
109 str = nonNull(str);
110 uint32_t len = static_cast<uint32_t>(strlen(str));
111 char* newData = reinterpret_cast<char*>(PX_ALLOC(len + 1, "string"));
112 PxMemCopy(newData, str, len);
113 newData[len] = 0;
114 return newData;
115}
116
117// Used for predictable bit fields.
118template <typename TDataType, uint8_t TNumBits, uint8_t TOffset, typename TInputType>
120{
121 // Create a mask that masks out the orginal value shift into place
122 static TDataType createOffsetMask()
123 {
124 return createMask() << TOffset;
125 }
126 // Create a mask of TNumBits number of tis
127 static TDataType createMask()
128 {
129 return static_cast<TDataType>((1 << TNumBits) - 1);
130 }
131 void setValue(TDataType& inCurrent, TInputType inData)
132 {
133 PX_ASSERT(inData < (1 << TNumBits));
134
135 // Create a mask to remove the current value.
136 TDataType theMask = ~(createOffsetMask());
137 // Clear out current value.
138 inCurrent = inCurrent & theMask;
139 // Create the new value.
140 TDataType theAddition = reinterpret_cast<TDataType>(inData << TOffset);
141 // or it into the existing value.
142 inCurrent = inCurrent | theAddition;
143 }
144
145 TInputType getValue(TDataType inCurrent)
146 {
147 return static_cast<TInputType>((inCurrent >> TOffset) & createMask());
148 }
149};
150
151}
152}
153#endif
Definition PxArray.h:53
Definition PxPvdObjectModelBaseTypes.h:345
#define PX_COMPILE_TIME_ASSERT(exp)
Definition PxPreprocessor.h:428
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemCopy(void *dest, const void *src, PxU32 count)
Copies the bytes of one memory block to another. The memory blocks must not overlap.
Definition PxMemory.h:83
Definition PxProfileMemoryEvents.h:83
Definition PxPvdObjectModelInternalTypes.h:56
Definition PxPvdObjectModelMetaData.h:308
Definition PxPvdObjectModelInternalTypes.h:41
Definition PxPvdObjectModelInternalTypes.h:61