Move vector property templates to separate header file.
Fixes the "weirdness" with MSVC complaining about incomplete class specs, since forward declarations (SGMathFwd.hxx) are used in props.hxx only. Only the few extended (vector) property templates require including the full SGMath.hxx (with MSVC) - and these are used in few places.
This commit is contained in:
parent
6e662fe4d6
commit
44db6d9e44
@ -10,6 +10,7 @@ set(HEADERS
|
||||
props_io.hxx
|
||||
propsfwd.hxx
|
||||
tiedpropertylist.hxx
|
||||
vectorPropTemplates.hxx
|
||||
)
|
||||
|
||||
set(SOURCES
|
||||
|
@ -15,9 +15,6 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
// working around MSVC weirdness with props.hxx and SGMathFwd
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
#include "propertyObject.hxx"
|
||||
|
||||
#include <simgear/structure/exception.hxx>
|
||||
|
@ -11,6 +11,7 @@
|
||||
#endif
|
||||
|
||||
#include "props.hxx"
|
||||
#include "vectorPropTemplates.hxx"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -63,13 +63,6 @@ inline T parseString(const std::string& str)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Extended properties
|
||||
template<>
|
||||
std::istream& readFrom<SGVec3d>(std::istream& stream, SGVec3d& result);
|
||||
template<>
|
||||
std::istream& readFrom<SGVec4d>(std::istream& stream, SGVec4d& result);
|
||||
|
||||
|
||||
/**
|
||||
* Property value types.
|
||||
*/
|
||||
@ -164,19 +157,6 @@ DEFINTERNALPROP(const char *, STRING);
|
||||
DEFINTERNALPROP(const char[], STRING);
|
||||
#undef DEFINTERNALPROP
|
||||
|
||||
template<>
|
||||
struct PropertyTraits<SGVec3d>
|
||||
{
|
||||
static const Type type_tag = VEC3D;
|
||||
enum { Internal = 0 };
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PropertyTraits<SGVec4d>
|
||||
{
|
||||
static const Type type_tag = VEC4D;
|
||||
enum { Internal = 0 };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -689,11 +669,6 @@ std::istream& SGRawBase<T, 0>::readFrom(std::istream& stream)
|
||||
return stream;
|
||||
}
|
||||
|
||||
template<>
|
||||
std::ostream& SGRawBase<SGVec3d>::printOn(std::ostream& stream) const;
|
||||
template<>
|
||||
std::ostream& SGRawBase<SGVec4d>::printOn(std::ostream& stream) const;
|
||||
|
||||
|
||||
/**
|
||||
* The smart pointer that manage reference counting
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <stdlib.h> // atof() atoi()
|
||||
#include <stdlib.h> // atof() atoi()
|
||||
|
||||
#include <simgear/sg_inlines.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
@ -25,11 +25,12 @@
|
||||
|
||||
#include "props.hxx"
|
||||
#include "props_io.hxx"
|
||||
#include "vectorPropTemplates.hxx"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <cstring> // strcmp()
|
||||
#include <cstring> // strcmp()
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// working around MSVC weirdness with props.hxx and SGMathFwd
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
#include "props.hxx"
|
||||
#include "props_io.hxx"
|
||||
|
||||
|
49
simgear/props/vectorPropTemplates.hxx
Normal file
49
simgear/props/vectorPropTemplates.hxx
Normal file
@ -0,0 +1,49 @@
|
||||
// vectorPropTemplates.hxx -- Templates Requiring Vector Properties
|
||||
//
|
||||
// Separate header file for any templates requiring SGVecXX vector types.
|
||||
|
||||
#ifndef __VECTORPROPTEMPLATES_HXX
|
||||
#define __VECTORPROPTEMPLATES_HXX
|
||||
|
||||
#include "props.hxx"
|
||||
|
||||
// The templates below depend on the full SGMath.hxx include. Forward
|
||||
// declarations (SGMathFwd.hxx) would be insufficient here (at least with MSVC).
|
||||
#include <simgear/math/SGMath.hxx>
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
|
||||
// Extended properties
|
||||
template<>
|
||||
std::istream& readFrom<SGVec3d>(std::istream& stream, SGVec3d& result);
|
||||
template<>
|
||||
std::istream& readFrom<SGVec4d>(std::istream& stream, SGVec4d& result);
|
||||
|
||||
namespace props
|
||||
{
|
||||
|
||||
template<>
|
||||
struct PropertyTraits<SGVec3d>
|
||||
{
|
||||
static const Type type_tag = VEC3D;
|
||||
enum { Internal = 0 };
|
||||
};
|
||||
|
||||
template<>
|
||||
struct PropertyTraits<SGVec4d>
|
||||
{
|
||||
static const Type type_tag = VEC4D;
|
||||
enum { Internal = 0 };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
std::ostream& SGRawBase<SGVec3d>::printOn(std::ostream& stream) const;
|
||||
template<>
|
||||
std::ostream& SGRawBase<SGVec4d>::printOn(std::ostream& stream) const;
|
||||
|
||||
#endif // __VECTORPROPTEMPLATES_HXX
|
||||
|
||||
// end of vectorPropTemplates.hxx
|
@ -74,7 +74,7 @@
|
||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||
#include <simgear/structure/OSGUtils.hxx>
|
||||
#include <simgear/structure/SGExpression.hxx>
|
||||
|
||||
#include <simgear/props/vectorPropTemplates.hxx>
|
||||
|
||||
|
||||
namespace simgear
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||
#include <simgear/structure/OSGUtils.hxx>
|
||||
#include <simgear/props/vectorPropTemplates.hxx>
|
||||
|
||||
namespace simgear
|
||||
{
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
|
||||
#include <simgear/props/props_io.hxx>
|
||||
#include <simgear/props/vectorPropTemplates.hxx>
|
||||
#include <simgear/scene/model/model.hxx>
|
||||
#include <simgear/scene/util/RenderConstants.hxx>
|
||||
#include <simgear/scene/util/StateAttributeFactory.hxx>
|
||||
@ -479,7 +480,7 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options)
|
||||
makeChild(propRoot, "inherits-from")->setStringValue(effect);
|
||||
SGPropertyNode* paramProp = makeChild(propRoot, "parameters");
|
||||
SGPropertyNode* materialProp = makeChild(paramProp, "material");
|
||||
makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient));
|
||||
makeChild(materialProp, "ambient")->setValue(SGVec4d(ambient));
|
||||
makeChild(materialProp, "diffuse")->setValue(SGVec4d(diffuse));
|
||||
makeChild(materialProp, "specular")->setValue(SGVec4d(specular));
|
||||
makeChild(materialProp, "emissive")->setValue(SGVec4d(emission));
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <osg/Geometry>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <simgear/props/vectorPropTemplates.hxx>
|
||||
#include <simgear/scene/material/EffectGeode.hxx>
|
||||
#include <simgear/scene/material/Technique.hxx>
|
||||
#include <simgear/scene/material/Pass.hxx>
|
||||
|
Loading…
Reference in New Issue
Block a user