Update/simplify property interpolation to latest SimGear changes
This commit is contained in:
parent
b0249bad98
commit
1e4ba18284
3 changed files with 9 additions and 46 deletions
|
@ -44,7 +44,6 @@
|
||||||
#include "fg_os.hxx"
|
#include "fg_os.hxx"
|
||||||
#include "fg_commands.hxx"
|
#include "fg_commands.hxx"
|
||||||
#include "fg_props.hxx"
|
#include "fg_props.hxx"
|
||||||
#include "FGInterpolator.hxx"
|
|
||||||
#include "globals.hxx"
|
#include "globals.hxx"
|
||||||
#include "logger.hxx"
|
#include "logger.hxx"
|
||||||
#include "util.hxx"
|
#include "util.hxx"
|
||||||
|
@ -900,21 +899,10 @@ do_property_randomize (const SGPropertyNode * arg)
|
||||||
static bool
|
static bool
|
||||||
do_property_interpolate (const SGPropertyNode * arg)
|
do_property_interpolate (const SGPropertyNode * arg)
|
||||||
{
|
{
|
||||||
FGInterpolator* mgr =
|
|
||||||
static_cast<FGInterpolator*>
|
|
||||||
(
|
|
||||||
globals->get_subsystem_mgr()
|
|
||||||
->get_group(SGSubsystemMgr::INIT)
|
|
||||||
->get_subsystem("prop-interpolator")
|
|
||||||
);
|
|
||||||
|
|
||||||
if( !mgr )
|
|
||||||
{
|
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "No property interpolator available");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SGPropertyNode * prop = get_prop(arg);
|
SGPropertyNode * prop = get_prop(arg);
|
||||||
|
if( !prop )
|
||||||
|
return false;
|
||||||
|
|
||||||
simgear::PropertyList time_nodes = arg->getChildren("time");
|
simgear::PropertyList time_nodes = arg->getChildren("time");
|
||||||
simgear::PropertyList rate_nodes = arg->getChildren("rate");
|
simgear::PropertyList rate_nodes = arg->getChildren("rate");
|
||||||
|
|
||||||
|
@ -966,16 +954,13 @@ do_property_interpolate (const SGPropertyNode * arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr->interpolate
|
return prop->interpolate
|
||||||
(
|
(
|
||||||
prop,
|
|
||||||
arg->getStringValue("type", "numeric"),
|
arg->getStringValue("type", "numeric"),
|
||||||
value_nodes,
|
value_nodes,
|
||||||
deltas,
|
deltas,
|
||||||
arg->getStringValue("easing", "linear")
|
arg->getStringValue("easing", "linear")
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -570,10 +570,10 @@ void fgCreateSubsystems() {
|
||||||
// Initialize the property interpolator subsystem. Put into the INIT
|
// Initialize the property interpolator subsystem. Put into the INIT
|
||||||
// group because the "nasal" subsystem may need it at GENERAL take-down.
|
// group because the "nasal" subsystem may need it at GENERAL take-down.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
globals->add_subsystem( "prop-interpolator",
|
FGInterpolator* interp = new FGInterpolator;
|
||||||
new FGInterpolator,
|
interp->setRealtimeProperty(fgGetNode("/sim/time/delta-realtime-sec", true));
|
||||||
SGSubsystemMgr::INIT );
|
globals->add_subsystem("prop-interpolator", interp, SGSubsystemMgr::INIT);
|
||||||
|
SGPropertyNode::setInterpolationMgr(interp);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Add the FlightGear property utilities.
|
// Add the FlightGear property utilities.
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <Main/util.hxx>
|
#include <Main/util.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Main/FGInterpolator.hxx>
|
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
|
@ -513,19 +512,6 @@ static naRef f_cmdarg(naContext c, naRef me, int argc, naRef* args)
|
||||||
// value/delta numbers.
|
// value/delta numbers.
|
||||||
static naRef f_interpolate(naContext c, naRef me, int argc, naRef* args)
|
static naRef f_interpolate(naContext c, naRef me, int argc, naRef* args)
|
||||||
{
|
{
|
||||||
FGInterpolator* mgr =
|
|
||||||
static_cast<FGInterpolator*>
|
|
||||||
(
|
|
||||||
globals->get_subsystem_mgr()
|
|
||||||
->get_group(SGSubsystemMgr::INIT)
|
|
||||||
->get_subsystem("prop-interpolator")
|
|
||||||
);
|
|
||||||
if( !mgr )
|
|
||||||
{
|
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "No property interpolator available");
|
|
||||||
return naNil();
|
|
||||||
};
|
|
||||||
|
|
||||||
SGPropertyNode* node;
|
SGPropertyNode* node;
|
||||||
naRef prop = argc > 0 ? args[0] : naNil();
|
naRef prop = argc > 0 ? args[0] : naNil();
|
||||||
if(naIsString(prop)) node = fgGetNode(naStr_data(prop), true);
|
if(naIsString(prop)) node = fgGetNode(naStr_data(prop), true);
|
||||||
|
@ -549,15 +535,7 @@ static naRef f_interpolate(naContext c, naRef me, int argc, naRef* args)
|
||||||
deltas.push_back(naNumValue(naVec_get(curve, 2*i+1)).num);
|
deltas.push_back(naNumValue(naVec_get(curve, 2*i+1)).num);
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr->interpolate
|
node->interpolate("numeric", value_nodes, deltas, "linear");
|
||||||
(
|
|
||||||
node,
|
|
||||||
"numeric",
|
|
||||||
value_nodes,
|
|
||||||
deltas,
|
|
||||||
"linear"
|
|
||||||
);
|
|
||||||
|
|
||||||
return naNil();
|
return naNil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue