Jump to content
  • Advertisement
Sign in to follow this  
Quat

Supporting Various "Position" formats

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!