Model relative property tree root binding.
This fixes the animation bindings to use the defined property tree root - to support multiplayer (or other) model that can bind to the correct part of the property tree. Requires a corresponding fix in fg to allow the command methods to take an optional root parameter. What this means is that when inside someone else's multiplayer model (e.g. backseat, or co-pilot), the multipalyer (AI) model will correctly modify properties inside the correct part of the property tree inside (/ai), rather than modifying the properties inside the same part of the tree as the non-ai model. This means that a properly setup model will operate within it's own space in the property tree; and permit more generic multiplayer code to be written. This is probably responsible for some of the pollution of the /sim property tree with MP aircraft properties.
This commit is contained in:
@@ -69,7 +69,9 @@ SGBinding::read(const SGPropertyNode* node, SGPropertyNode* root)
|
||||
}
|
||||
|
||||
_arg = const_cast<SGPropertyNode*>(node);
|
||||
_root = const_cast<SGPropertyNode*>(root);
|
||||
_setting = 0;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -89,7 +91,7 @@ SGBinding::innerFire () const
|
||||
SG_LOG(SG_INPUT, SG_WARN, "No command attached to binding:" << _command_name);
|
||||
} else {
|
||||
try {
|
||||
if (!(*_command)(_arg)) {
|
||||
if (!(*_command)(_arg, _root)) {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "Failed to execute command "
|
||||
<< _command_name);
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@ private:
|
||||
mutable SGCommandMgr::Command* _command;
|
||||
mutable SGPropertyNode_ptr _arg;
|
||||
mutable SGPropertyNode_ptr _setting;
|
||||
mutable SGPropertyNode_ptr _root;
|
||||
};
|
||||
|
||||
typedef SGSharedPtr<SGBinding> SGBinding_ptr;
|
||||
|
||||
@@ -75,7 +75,7 @@ SGCommandMgr::getCommandNames () const
|
||||
}
|
||||
|
||||
bool
|
||||
SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg) const
|
||||
SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg, SGPropertyNode *root) const
|
||||
{
|
||||
Command* command = getCommand(name);
|
||||
if (command == 0)
|
||||
@@ -86,7 +86,7 @@ SGCommandMgr::execute (const std::string &name, const SGPropertyNode * arg) cons
|
||||
|
||||
try
|
||||
{
|
||||
return (*command)(arg);
|
||||
return (*command)(arg, root);
|
||||
}
|
||||
catch(sg_exception& e)
|
||||
{
|
||||
|
||||
@@ -41,11 +41,11 @@ public:
|
||||
{
|
||||
public:
|
||||
virtual ~Command() { }
|
||||
virtual bool operator()(const SGPropertyNode * arg) = 0;
|
||||
virtual bool operator()(const SGPropertyNode * arg, SGPropertyNode *root) = 0;
|
||||
};
|
||||
|
||||
|
||||
typedef bool (*command_t) (const SGPropertyNode * arg);
|
||||
typedef bool (*command_t) (const SGPropertyNode * arg, SGPropertyNode *root);
|
||||
|
||||
private:
|
||||
class FunctionCommand : public Command
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
FunctionCommand( command_t fun )
|
||||
: f_(fun) {}
|
||||
|
||||
virtual bool operator()(const SGPropertyNode * arg) { return (*f_)(arg); }
|
||||
virtual bool operator()(const SGPropertyNode * arg, SGPropertyNode *root) { return (*f_)(arg, root); }
|
||||
private:
|
||||
command_t f_;
|
||||
};
|
||||
@@ -66,9 +66,9 @@ private:
|
||||
MethodCommand( const ObjPtr& pObj, MemFn pMemFn ) :
|
||||
pObj_(pObj), pMemFn_(pMemFn) {}
|
||||
|
||||
virtual bool operator()(const SGPropertyNode * arg)
|
||||
virtual bool operator()(const SGPropertyNode * arg, SGPropertyNode *root)
|
||||
{
|
||||
return ((*pObj_).*pMemFn_)(arg);
|
||||
return ((*pObj_).*pMemFn_)(arg,root);
|
||||
}
|
||||
private:
|
||||
ObjPtr pObj_;
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
* @return true if the command is present and executes successfully,
|
||||
* false otherwise.
|
||||
*/
|
||||
virtual bool execute (const std::string &name, const SGPropertyNode * arg) const;
|
||||
virtual bool execute (const std::string &name, const SGPropertyNode * arg, SGPropertyNode *root) const;
|
||||
|
||||
/**
|
||||
* Remove a command registration
|
||||
|
||||
Reference in New Issue
Block a user