add methods to export the check if positions or normals are double and get them as doubles

This commit is contained in:
Max Lyon
2020-02-05 22:11:10 +01:00
parent c92a666658
commit 2356364085
3 changed files with 31 additions and 5 deletions

View File

@@ -289,7 +289,7 @@ namespace OMFormat {
inline size_t chunk_header_size( void ) { return sizeof(uint16); }
/// Return the size of a scale in bytes.
/// Return the size of a scaler in bytes.
inline size_t scalar_size( const Chunk::Header& _hdr )
{
return _hdr.float_ ? (0x01 << _hdr.bits_) : (0x04 << _hdr.bits_);

View File

@@ -90,7 +90,11 @@ public:
// get vertex data
virtual Vec3f point(VertexHandle _vh) const = 0;
virtual Vec3d pointd(VertexHandle _vh) const = 0;
virtual bool is_point_double() const = 0;
virtual Vec3f normal(VertexHandle _vh) const = 0;
virtual Vec3d normald(VertexHandle _vh) const = 0;
virtual bool is_normal_double() const = 0;
virtual Vec3uc color(VertexHandle _vh) const = 0;
virtual Vec4uc colorA(VertexHandle _vh) const = 0;
virtual Vec3ui colori(VertexHandle _vh) const = 0;

View File

@@ -94,6 +94,21 @@ public:
return vector_cast<Vec3f>(mesh_.point(_vh));
}
Vec3d pointd(VertexHandle _vh) const override
{
return vector_cast<Vec3d>(mesh_.point(_vh));
}
bool is_point_double() const override
{
return OMFormat::is_double(typename Mesh::Point()[0]);
}
bool is_normal_double() const override
{
return OMFormat::is_double(typename Mesh::Normal()[0]);
}
Vec3f normal(VertexHandle _vh) const override
{
return (mesh_.has_vertex_normals()
@@ -101,6 +116,13 @@ public:
: Vec3f(0.0f, 0.0f, 0.0f));
}
Vec3d normald(VertexHandle _vh) const override
{
return (mesh_.has_vertex_normals()
? vector_cast<Vec3d>(mesh_.normal(_vh))
: Vec3d(0.0f, 0.0f, 0.0f));
}
Vec3uc color(VertexHandle _vh) const override
{
return (mesh_.has_vertex_colors()