Переглянути джерело

Trying to avoid additional memory allocations

Jorrit Rouwe 4 роки тому
батько
коміт
b1ebd82008

+ 1 - 0
Jolt/Physics/Collision/Shape/CompoundShape.cpp

@@ -325,6 +325,7 @@ void CompoundShape::RestoreBinaryState(StreamIn &inStream)
 void CompoundShape::SaveSubShapeState(ShapeList &outSubShapes) const
 { 
 	outSubShapes.clear();
+	outSubShapes.reserve(mSubShapes.size());
 	for (const SubShape &shape : mSubShapes)
 		outSubShapes.push_back(shape.mShape);
 }

+ 2 - 1
Jolt/Physics/Collision/Shape/ConvexShape.cpp

@@ -573,7 +573,8 @@ void ConvexShape::RestoreBinaryState(StreamIn &inStream)
 
 void ConvexShape::SaveMaterialState(PhysicsMaterialList &outMaterials) const
 { 
-	outMaterials = { mMaterial }; 
+	outMaterials.clear();
+	outMaterials.push_back(mMaterial);
 }
 
 void ConvexShape::RestoreMaterialState(const PhysicsMaterialRefC *inMaterials, uint inNumMaterials)