From Michael Platings with tweaks from Robert Osfield, added Options::s/getPrecisionHint(..) to allow apps to hint to plugins about how to handle double precision geometry data.

This commit is contained in:
Robert Osfield 2010-04-13 13:06:27 +00:00
parent 51924431cd
commit 88f1b8f19a
2 changed files with 33 additions and 0 deletions

View File

@ -60,6 +60,30 @@ class OSGDB_EXPORT Options : public osg::Object
CACHE_SHADERS
};
/// Bit mask for which geometry attributes should be imported with double precision where source data is held in double precision
/// This is useful for data that will be pre-processed before rendering.
/// In general the geometry should be converted to floating point before rendering to ensure good performance.
enum PrecisionHint
{
FLOAT_PRECISION_ALL = 0,
DOUBLE_PRECISION_VERTEX = 1<<0,
DOUBLE_PRECISION_NORMAL = 1<<1,
DOUBLE_PRECISION_COLOR = 1<<2,
DOUBLE_PRECISION_SECONDARY_COLOR = 1<<3,
DOUBLE_PRECISION_FOG_COORD = 1<<4,
DOUBLE_PRECISION_TEX_COORD = 1<<5,
DOUBLE_PRECISION_VERTEX_ATTRIB = 1<<6,
DOUBLE_PRECISION_ALL = DOUBLE_PRECISION_VERTEX |
DOUBLE_PRECISION_NORMAL |
DOUBLE_PRECISION_COLOR |
DOUBLE_PRECISION_SECONDARY_COLOR |
DOUBLE_PRECISION_FOG_COORD |
DOUBLE_PRECISION_TEX_COORD |
DOUBLE_PRECISION_VERTEX_ATTRIB
};
/// range of options of whether to build kdtrees automatically on loading
enum BuildKdTreesHint
{
@ -72,12 +96,14 @@ class OSGDB_EXPORT Options : public osg::Object
Options():
osg::Object(true),
_objectCacheHint(CACHE_ARCHIVES),
_precisionHint(FLOAT_PRECISION_ALL),
_buildKdTreesHint(NO_PREFERENCE) {}
Options(const std::string& str):
osg::Object(true),
_str(str),
_objectCacheHint(CACHE_ARCHIVES),
_precisionHint(FLOAT_PRECISION_ALL),
_buildKdTreesHint(NO_PREFERENCE) {}
Options(const Options& options,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
@ -108,6 +134,11 @@ class OSGDB_EXPORT Options : public osg::Object
/** Get whether the Registry::ObjectCache should be used by default.*/
CacheHintOptions getObjectCacheHint() const { return _objectCacheHint; }
/** Set which geometry attributes plugins should import at double precision. */
void setPrecisionHint(PrecisionHint hint) { _precisionHint = hint; }
/** Get which geometry attributes plugins should import at double precision. */
PrecisionHint getPrecisionHint() const { return _precisionHint; }
/** Set whether the KdTrees should be built for geometry in the loader model. */
void setBuildKdTreesHint(BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
@ -200,6 +231,7 @@ class OSGDB_EXPORT Options : public osg::Object
std::string _str;
FilePathList _databasePaths;
CacheHintOptions _objectCacheHint;
PrecisionHint _precisionHint;
BuildKdTreesHint _buildKdTreesHint;
osg::ref_ptr<AuthenticationMap> _authenticationMap;

View File

@ -21,6 +21,7 @@ Options::Options(const Options& options,const osg::CopyOp& copyop):
_str(options._str),
_databasePaths(options._databasePaths),
_objectCacheHint(options._objectCacheHint),
_precisionHint(options._precisionHint),
_buildKdTreesHint(options._buildKdTreesHint),
_pluginData(options._pluginData),
_pluginStringData(options._pluginStringData),