Remove unecessary dependency from libSimGearCore on libSimGearScene.
This commit is contained in:
@@ -4,6 +4,7 @@ include (SimGearComponent)
|
|||||||
set(HEADERS
|
set(HEADERS
|
||||||
ResourceManager.hxx
|
ResourceManager.hxx
|
||||||
interpolator.hxx
|
interpolator.hxx
|
||||||
|
make_new.hxx
|
||||||
sg_dir.hxx
|
sg_dir.hxx
|
||||||
sg_path.hxx
|
sg_path.hxx
|
||||||
sgstream.hxx
|
sgstream.hxx
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// Helper functions which created objects with new.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2013 Thomas Geymayer <tomgey@gmail.com>
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Library General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Library General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Library General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
#ifndef SG_MAKE_NEW_HXX_
|
||||||
|
#define SG_MAKE_NEW_HXX_
|
||||||
|
|
||||||
|
namespace simgear
|
||||||
|
{
|
||||||
|
template<class T>
|
||||||
|
T* make_new()
|
||||||
|
{ return new T; }
|
||||||
|
|
||||||
|
template<class T, class A1>
|
||||||
|
T* make_new(const A1& a1)
|
||||||
|
{ return new T(a1); }
|
||||||
|
|
||||||
|
template<class T, class A1, class A2>
|
||||||
|
T* make_new(const A1& a1, const A2& a2)
|
||||||
|
{ return new T(a1, a2); }
|
||||||
|
|
||||||
|
template<class Base, class Derived>
|
||||||
|
Base* make_new_derived()
|
||||||
|
{ return new Derived; }
|
||||||
|
|
||||||
|
template<class Base, class Derived, class A1>
|
||||||
|
Base* make_new_derived(const A1& a1)
|
||||||
|
{ return new Derived(a1); }
|
||||||
|
|
||||||
|
template<class Base, class Derived, class A1, class A2>
|
||||||
|
Base* make_new_derived(const A1& a1, const A2& a2)
|
||||||
|
{ return new Derived(a1, a2); }
|
||||||
|
|
||||||
|
// Add more if needed (Variadic templates would be really nice!)
|
||||||
|
|
||||||
|
} // namespace simgear
|
||||||
|
|
||||||
|
#endif /* SG_MAKE_NEW_HXX_ */
|
||||||
@@ -18,14 +18,7 @@
|
|||||||
|
|
||||||
#include "PropertyInterpolationMgr.hxx"
|
#include "PropertyInterpolationMgr.hxx"
|
||||||
#include "PropertyInterpolator.hxx"
|
#include "PropertyInterpolator.hxx"
|
||||||
|
#include "props.hxx"
|
||||||
#include <simgear_config.h>
|
|
||||||
|
|
||||||
#ifndef SIMGEAR_HEADLESS
|
|
||||||
# include <simgear/scene/util/ColorInterpolator.hxx>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <simgear/props/props.hxx>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -36,9 +29,6 @@ namespace simgear
|
|||||||
PropertyInterpolationMgr::PropertyInterpolationMgr()
|
PropertyInterpolationMgr::PropertyInterpolationMgr()
|
||||||
{
|
{
|
||||||
addInterpolatorFactory<NumericInterpolator>("numeric");
|
addInterpolatorFactory<NumericInterpolator>("numeric");
|
||||||
#ifndef SIMGEAR_HEADLESS
|
|
||||||
addInterpolatorFactory<ColorInterpolator>("color");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for( size_t i = 0; easing_functions[i].name; ++i )
|
for( size_t i = 0; easing_functions[i].name; ++i )
|
||||||
addEasingFunction
|
addEasingFunction
|
||||||
@@ -128,7 +118,8 @@ namespace simgear
|
|||||||
}
|
}
|
||||||
|
|
||||||
PropertyInterpolatorRef interp;
|
PropertyInterpolatorRef interp;
|
||||||
interp = (*interpolator_factory->second)(target);
|
interp = (*interpolator_factory->second)();
|
||||||
|
interp->reset(target);
|
||||||
interp->_type = type;
|
interp->_type = type;
|
||||||
interp->_duration = duration;
|
interp->_duration = duration;
|
||||||
interp->_easing = easing_func->second;
|
interp->_easing = easing_func->second;
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
#ifndef SG_PROPERTY_INTERPOLATION_MGR_HXX_
|
#ifndef SG_PROPERTY_INTERPOLATION_MGR_HXX_
|
||||||
#define SG_PROPERTY_INTERPOLATION_MGR_HXX_
|
#define SG_PROPERTY_INTERPOLATION_MGR_HXX_
|
||||||
|
|
||||||
|
#include "PropertyInterpolator.hxx"
|
||||||
|
|
||||||
|
#include <simgear/misc/make_new.hxx>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/props/PropertyInterpolator.hxx>
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
@@ -45,8 +47,7 @@ namespace simgear
|
|||||||
public SGSubsystem
|
public SGSubsystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef PropertyInterpolator*
|
typedef PropertyInterpolator* (*InterpolatorFactory)();
|
||||||
(*InterpolatorFactory)(const SGPropertyNode* target);
|
|
||||||
|
|
||||||
PropertyInterpolationMgr();
|
PropertyInterpolationMgr();
|
||||||
|
|
||||||
@@ -90,7 +91,11 @@ namespace simgear
|
|||||||
template<class T>
|
template<class T>
|
||||||
void addInterpolatorFactory(const std::string& type)
|
void addInterpolatorFactory(const std::string& type)
|
||||||
{
|
{
|
||||||
addInterpolatorFactory(type, &PropertyInterpolator::create<T>);
|
addInterpolatorFactory
|
||||||
|
(
|
||||||
|
type,
|
||||||
|
&simgear::make_new_derived<PropertyInterpolator, T>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace simgear
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
PropertyInterpolator::PropertyInterpolator():
|
PropertyInterpolator::PropertyInterpolator():
|
||||||
_duration(1),
|
_duration(1),
|
||||||
_cur_t(-1)
|
_cur_t(0)
|
||||||
{
|
{
|
||||||
setEasingFunction(0);
|
setEasingFunction(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,23 +67,6 @@ namespace simgear
|
|||||||
|
|
||||||
const std::string& getType() const { return _type; }
|
const std::string& getType() const { return _type; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Create new animation for given property.
|
|
||||||
*
|
|
||||||
* @param prop Property to be animated
|
|
||||||
* @param target Property containing target value
|
|
||||||
*/
|
|
||||||
template<class Derived>
|
|
||||||
static PropertyInterpolator* create(const SGPropertyNode* target)
|
|
||||||
{
|
|
||||||
assert(target);
|
|
||||||
|
|
||||||
PropertyInterpolator* interp = new Derived;
|
|
||||||
interp->reset(target);
|
|
||||||
|
|
||||||
return interp;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class PropertyInterpolationMgr;
|
friend class PropertyInterpolationMgr;
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,8 @@ int main (int ac, char ** av)
|
|||||||
SGPropertyNode color_node, color_arg;
|
SGPropertyNode color_node, color_arg;
|
||||||
color_arg.setStringValue("#000000");
|
color_arg.setStringValue("#000000");
|
||||||
|
|
||||||
simgear::PropertyInterpolator* interp =
|
simgear::PropertyInterpolator* interp = new simgear::ColorInterpolator;
|
||||||
simgear::PropertyInterpolator
|
interp->reset(&color_arg);
|
||||||
::create<simgear::ColorInterpolator>(&color_arg);
|
|
||||||
|
|
||||||
interp->update(&color_node, 0.5); // with no color it should immediately set to the target
|
interp->update(&color_node, 0.5); // with no color it should immediately set to the target
|
||||||
VERIFY_NODE_STR(color_node, "rgb(0,0,0)");
|
VERIFY_NODE_STR(color_node, "rgb(0,0,0)");
|
||||||
|
|||||||
@@ -21,4 +21,3 @@
|
|||||||
|
|
||||||
#cmakedefine SYSTEM_EXPAT
|
#cmakedefine SYSTEM_EXPAT
|
||||||
#cmakedefine ENABLE_SOUND
|
#cmakedefine ENABLE_SOUND
|
||||||
#cmakedefine SIMGEAR_HEADLESS
|
|
||||||
Reference in New Issue
Block a user