Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Supporting Various "Position" formats


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Quat   Members   -  Reputation: 414

Like
0Likes
Like

Posted 08 July 2014 - 09:20 AM

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*

}

 

 


-----Quat

Sponsor:

#2 ProjectEW   Members   -  Reputation: 119

Like
0Likes
Like

Posted 12 July 2014 - 01:48 PM

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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS