# Supporting Various "Position" formats

This topic is 1288 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So far my engine always used 32-bit float3 to store position in a vertex.  To integrate with a middleware package, my engine needs to support half position 16-bit float4.  Some parts of my engine need to read the vertex data on the CPU side (say to compute a bounding box).  Does someone have a clean solution for this besides if/else states like:

if(half format)

{

cast to half*

}

else

{

cast to float*

}

##### Share on other sites

Depending on how exactly you are accessing and handling the vectors, you could make an overload of your vector handling function that accepts only half-vectors, casts it to a float vector, then passes it onto the overload of the function that takes a full size vector.

For example:

void calculateAABB(Vector3f v)
{
...
}

void calculateAABB(Vector3s v)
{
calculateAABB((Vector3f)v);
}


Alternatively, if you are the one writing the vector classes, you could write an implicit cast in both vector classes to the other type, so the two can be used interchangeably. However, this code practice may be frowned upon, I don't use much C++.