Archive 17/01/2023.

Fastest way to convert VariantVector to Vector<T>?

godan

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?

1vanK

(Some offtopic) Use

PODVector<Vector3>

istead

Vector<Vector3>

for speed.

Eugene

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.