Fastest way to convert VariantVector to Vector<T>?


#1

In my projects, I do a ton of work with VariantVectors and Variants in general. Something that comes up a lot is that I have say, a typed Vector:

Vector<Vector3> myPoints;

and I want to convert this to a VariantVector. The obvious way is:

VariantVector myVarVec;
int numPoints = myPoints.Size();
myVarVec.Resize(numPoints);

for(int i = 0; i < numPoints; i++){
myVarVec[i] = myPoints[i];
}

Is there a mem_copy I can do? A cast?


#2

(Some offtopic) Use

PODVector<Vector3>

istead

Vector<Vector3>

for speed.


#3

The only way is that one.
You may perform per-element cast from Variant to Vector3, but I am unsure that it would be faster.