Tie the count into the property tree instead of using snprintf every frame. Add the life-timer to the property tree under sim/time/elapsed-sec for AI object animation (blending and/or scaling).
This commit is contained in:
parent
fdab44652e
commit
d2d27f2d76
3 changed files with 13 additions and 8 deletions
|
@ -49,10 +49,12 @@ bool FGAIBallistic::init() {
|
||||||
|
|
||||||
void FGAIBallistic::bind() {
|
void FGAIBallistic::bind() {
|
||||||
// FGAIBase::bind();
|
// FGAIBase::bind();
|
||||||
|
props->tie("sim/time/elapsed-sec", SGRawValuePointer<double>(&life_timer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIBallistic::unbind() {
|
void FGAIBallistic::unbind() {
|
||||||
// FGAIBase::unbind();
|
// FGAIBase::unbind();
|
||||||
|
props->untie("sim/time/elapsed-sec");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAIBallistic::update(double dt) {
|
void FGAIBallistic::update(double dt) {
|
||||||
|
|
|
@ -53,6 +53,11 @@ SubmodelSystem::bind ()
|
||||||
void
|
void
|
||||||
SubmodelSystem::unbind ()
|
SubmodelSystem::unbind ()
|
||||||
{
|
{
|
||||||
|
submodel_iterator = submodels.begin();
|
||||||
|
while(submodel_iterator != submodels.end()) {
|
||||||
|
(*submodel_iterator)->prop->untie("count");
|
||||||
|
++submodel_iterator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -66,10 +71,6 @@ SubmodelSystem::update (double dt)
|
||||||
if ((*submodel_iterator)->trigger->getBoolValue()) {
|
if ((*submodel_iterator)->trigger->getBoolValue()) {
|
||||||
if ((*submodel_iterator)->count != 0) {
|
if ((*submodel_iterator)->count != 0) {
|
||||||
release( (*submodel_iterator), dt);
|
release( (*submodel_iterator), dt);
|
||||||
// now update the "count" property for this submodel
|
|
||||||
char name[80];
|
|
||||||
snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i);
|
|
||||||
fgSetInt(name, (*submodel_iterator)->count);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++submodel_iterator;
|
++submodel_iterator;
|
||||||
|
@ -119,8 +120,8 @@ SubmodelSystem::load ()
|
||||||
int count = root.nChildren();
|
int count = root.nChildren();
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
// cout << "Reading submodel " << i << endl;
|
// cout << "Reading submodel " << i << endl;
|
||||||
|
SGPropertyNode *prop;
|
||||||
submodel* sm = new submodel;
|
submodel* sm = new submodel;
|
||||||
submodels.push_back( sm );
|
|
||||||
SGPropertyNode * entry_node = root.getChild(i);
|
SGPropertyNode * entry_node = root.getChild(i);
|
||||||
sm->trigger = fgGetNode(entry_node->getStringValue("trigger", "none"), true);
|
sm->trigger = fgGetNode(entry_node->getStringValue("trigger", "none"), true);
|
||||||
sm->name = entry_node->getStringValue("name", "none_defined");
|
sm->name = entry_node->getStringValue("name", "none_defined");
|
||||||
|
@ -141,9 +142,10 @@ SubmodelSystem::load ()
|
||||||
sm->trigger->setBoolValue(false);
|
sm->trigger->setBoolValue(false);
|
||||||
sm->timer = sm->delay;
|
sm->timer = sm->delay;
|
||||||
|
|
||||||
char name[80];
|
sm->prop = fgGetNode("/systems/submodels/submodel", i, true);
|
||||||
snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i);
|
sm->prop->tie("count", SGRawValuePointer<int>(&(sm->count)));
|
||||||
fgSetInt(name, sm->count);
|
|
||||||
|
submodels.push_back( sm );
|
||||||
}
|
}
|
||||||
|
|
||||||
submodel_iterator = submodels.begin();
|
submodel_iterator = submodels.begin();
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SGPropertyNode_ptr trigger;
|
SGPropertyNode_ptr trigger;
|
||||||
|
SGPropertyNode_ptr prop;
|
||||||
string name;
|
string name;
|
||||||
string model;
|
string model;
|
||||||
double speed;
|
double speed;
|
||||||
|
|
Loading…
Add table
Reference in a new issue