aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/Common/src/CmUtils.h
diff options
context:
space:
mode:
authorsschirm <[email protected]>2016-12-23 14:20:36 +0100
committersschirm <[email protected]>2016-12-23 14:56:17 +0100
commitef6937e69e8ee3f409cf9d460d5ad300a65d5924 (patch)
tree710426e8daa605551ce3f34b581897011101c30f /PhysX_3.4/Source/Common/src/CmUtils.h
parentInitial commit: (diff)
downloadphysx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.tar.xz
physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.zip
PhysX 3.4 / APEX 1.4 release candidate @21506124
Diffstat (limited to 'PhysX_3.4/Source/Common/src/CmUtils.h')
-rw-r--r--PhysX_3.4/Source/Common/src/CmUtils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/PhysX_3.4/Source/Common/src/CmUtils.h b/PhysX_3.4/Source/Common/src/CmUtils.h
index ad911fd7..febddbf2 100644
--- a/PhysX_3.4/Source/Common/src/CmUtils.h
+++ b/PhysX_3.4/Source/Common/src/CmUtils.h
@@ -284,6 +284,24 @@ void importInlineArray(Ps::InlineArray<T, N, Alloc>& a, PxDeserializationContext
Cm::importArray(a, context);
}
+template<class T>
+static PX_INLINE T* reserveContainerMemory(Ps::Array<T>& container, PxU32 nb)
+{
+ const PxU32 maxNbEntries = container.capacity();
+ const PxU32 requiredSize = container.size() + nb;
+
+ if(requiredSize>maxNbEntries)
+ {
+ const PxU32 naturalGrowthSize = maxNbEntries ? maxNbEntries*2 : 2;
+ const PxU32 newSize = PxMax(requiredSize, naturalGrowthSize);
+ container.reserve(newSize);
+ }
+
+ T* buf = container.end();
+ container.forceSize_Unsafe(requiredSize);
+ return buf;
+}
+
} // namespace Cm