From d2d27f2d767d3806e27997c219682689ec302456 Mon Sep 17 00:00:00 2001 From: ehofman Date: Mon, 30 Aug 2004 11:13:29 +0000 Subject: [PATCH] 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). --- src/AIModel/AIBallistic.cxx | 2 ++ src/Systems/submodel.cxx | 18 ++++++++++-------- src/Systems/submodel.hxx | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index e06bf9f4b..b6675ff05 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -49,10 +49,12 @@ bool FGAIBallistic::init() { void FGAIBallistic::bind() { // FGAIBase::bind(); + props->tie("sim/time/elapsed-sec", SGRawValuePointer(&life_timer)); } void FGAIBallistic::unbind() { // FGAIBase::unbind(); + props->untie("sim/time/elapsed-sec"); } void FGAIBallistic::update(double dt) { diff --git a/src/Systems/submodel.cxx b/src/Systems/submodel.cxx index 94e3ad76c..e87ef0e23 100644 --- a/src/Systems/submodel.cxx +++ b/src/Systems/submodel.cxx @@ -53,6 +53,11 @@ SubmodelSystem::bind () void SubmodelSystem::unbind () { + submodel_iterator = submodels.begin(); + while(submodel_iterator != submodels.end()) { + (*submodel_iterator)->prop->untie("count"); + ++submodel_iterator; + } } void @@ -66,10 +71,6 @@ SubmodelSystem::update (double dt) if ((*submodel_iterator)->trigger->getBoolValue()) { if ((*submodel_iterator)->count != 0) { 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; @@ -119,8 +120,8 @@ SubmodelSystem::load () int count = root.nChildren(); for (i = 0; i < count; i++) { // cout << "Reading submodel " << i << endl; + SGPropertyNode *prop; submodel* sm = new submodel; - submodels.push_back( sm ); SGPropertyNode * entry_node = root.getChild(i); sm->trigger = fgGetNode(entry_node->getStringValue("trigger", "none"), true); sm->name = entry_node->getStringValue("name", "none_defined"); @@ -141,9 +142,10 @@ SubmodelSystem::load () sm->trigger->setBoolValue(false); sm->timer = sm->delay; - char name[80]; - snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i); - fgSetInt(name, sm->count); + sm->prop = fgGetNode("/systems/submodels/submodel", i, true); + sm->prop->tie("count", SGRawValuePointer(&(sm->count))); + + submodels.push_back( sm ); } submodel_iterator = submodels.begin(); diff --git a/src/Systems/submodel.hxx b/src/Systems/submodel.hxx index f088173a0..5c5b2046a 100644 --- a/src/Systems/submodel.hxx +++ b/src/Systems/submodel.hxx @@ -27,6 +27,7 @@ public: typedef struct { SGPropertyNode_ptr trigger; + SGPropertyNode_ptr prop; string name; string model; double speed;