]> git.mxchange.org Git - simgear.git/commitdiff
hla: Add propper attribute dirty handling.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Fri, 2 Mar 2012 20:51:59 +0000 (21:51 +0100)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Fri, 2 Mar 2012 20:51:59 +0000 (21:51 +0100)
simgear/hla/HLAArrayDataElement.cxx
simgear/hla/HLAArrayDataElement.hxx
simgear/hla/HLABasicDataElement.cxx
simgear/hla/HLAFixedRecordDataElement.cxx
simgear/hla/HLAObjectInstance.cxx
simgear/hla/HLAVariantRecordDataElement.cxx

index 5fcbbd0a0ecc173ada7b6986d2d65c4b216e5d11..9f8f5aeb3fe095531baaaed924691a8add67b1fa 100644 (file)
@@ -111,6 +111,7 @@ HLAArrayDataElement::setNumElements(unsigned size)
     _elementVector.resize(size);
     for (unsigned i = oldSize; i < size; ++i)
         _elementVector[i] = newElement(i);
+    setDirty(true);
     return true;
 }
 
@@ -177,6 +178,7 @@ HLAArrayDataElement::setElement(unsigned index, HLADataElement* value)
     _elementVector[index] = value;
     if (value)
         value->attachStamp(*this);
+    setDirty(true);
 }
 
 void
@@ -252,6 +254,7 @@ HLAVariantArrayDataElement::setNumElements(unsigned size)
     _elementVector.resize(size);
     for (unsigned i = oldSize; i < size; ++i)
         _elementVector[i] = newElement();
+    setDirty(true);
     return true;
 }
 
@@ -318,6 +321,7 @@ HLAVariantArrayDataElement::setElement(unsigned index, HLAVariantRecordDataEleme
     _elementVector[index] = value;
     if (value)
         value->attachStamp(*this);
+    setDirty(true);
 }
 
 void
index 4557d006afa068e2ef10832c34e02a2bdb10a0bd..72f1478b878476d99ae371868cc1e0819a7b197c 100644 (file)
@@ -139,7 +139,7 @@ public:
     const std::string& getValue() const
     { return _value; }
     void setValue(const std::string& value)
-    { _value = value; }
+    { _value = value; setDirty(true); }
 
     virtual bool setNumElements(unsigned count)
     {
@@ -216,7 +216,7 @@ public:
     const SGVec2<T>& getValue() const
     { return _value; }
     void setValue(const SGVec2<T>& value)
-    { _value = value; }
+    { _value = value; setDirty(true); }
 
     virtual bool setNumElements(unsigned count)
     {
@@ -308,7 +308,7 @@ public:
     const SGVec3<T>& getValue() const
     { return _value; }
     void setValue(const SGVec3<T>& value)
-    { _value = value; }
+    { _value = value; setDirty(true); }
 
     virtual bool setNumElements(unsigned count)
     {
@@ -400,7 +400,7 @@ public:
     const SGVec4<T>& getValue() const
     { return _value; }
     void setValue(const SGVec4<T>& value)
-    { _value = value; }
+    { _value = value; setDirty(true); }
 
     virtual bool setNumElements(unsigned count)
     {
@@ -492,7 +492,7 @@ public:
     const SGQuat<T>& getValue() const
     { return _value; }
     void setValue(const SGQuat<T>& value)
-    { _value = value; }
+    { _value = value; setDirty(true); }
 
     virtual bool setNumElements(unsigned count)
     {
index f68cad36df13e7622cddeef3423496dd84b789d1..c4b985b91161ee03cda4c51664c82b8d20dee83b 100644 (file)
@@ -125,6 +125,7 @@ void
 HLA##type##DataElement::setValue(ctype value)                                                     \
 {                                                                                                 \
     _value = value;                                                                               \
+    setDirty(true);                                                                               \
 }
 
 IMPLEMENT_TYPED_HLA_BASIC_DATA_ELEMENT(Char, char);
index d04c273233ad843b703d7a2f3ea78883725f88bc..9a0311bdec0a83b2ef8ee1447db031e291c36345 100644 (file)
@@ -187,6 +187,7 @@ HLAFixedRecordDataElement::setField(unsigned index, HLADataElement* value)
     _fieldVector[index] = value;
     if (value)
         value->attachStamp(*this);
+    setDirty(true);
 }
 
 void
index f54ca8bb4598dd823884149e9abb62dd045051ca..a163c5953dbb12331ea3069d5736f7e42927c9ce 100644 (file)
@@ -121,8 +121,6 @@ HLAObjectInstance::setAttributeDataElement(unsigned index, const SGSharedPtr<HLA
     _attributeVector[index]._dataElement = dataElement;
     if (_attributeVector[index]._dataElement.valid())
         _attributeVector[index]._dataElement->createStamp();
-    if (getAttributeOwned(index))
-        encodeAttributeValue(index);
 }
 
 class HLAObjectInstance::DataElementFactoryVisitor : public HLADataElementFactoryVisitor {
@@ -477,9 +475,13 @@ HLAObjectInstance::encodeAttributeValues()
 {
     unsigned numAttributes = _attributeVector.size();
     for (unsigned i = 0; i < numAttributes;++i) {
-        if (!_attributeVector[i]._unconditionalUpdate)
-            continue;
-        encodeAttributeValue(i);
+        if (_attributeVector[i]._unconditionalUpdate) {
+            encodeAttributeValue(i);
+        } else if (_attributeVector[i]._enabledUpdate) {
+            const HLADataElement* dataElement = getAttributeDataElement(i);
+            if (dataElement && dataElement->getDirty())
+                encodeAttributeValue(i);
+        }
     }
 }
 
@@ -490,10 +492,11 @@ HLAObjectInstance::encodeAttributeValue(unsigned index)
         SG_LOG(SG_IO, SG_INFO, "Not updating inactive object!");
         return;
     }
-    const HLADataElement* dataElement = getAttributeDataElement(index);
+    HLADataElement* dataElement = getAttributeDataElement(index);
     if (!dataElement)
         return;
     _rtiObjectInstance->encodeAttributeData(index, *dataElement);
+    dataElement->setDirty(false);
 }
 
 void
index e3ef35a1368e9a13b42a0d91a74e37247ceae5ba..5dac6d52ba82b4b042b38fc4dcb7b4f232ff1652 100644 (file)
@@ -126,6 +126,7 @@ HLAVariantRecordDataElement::setAlternativeIndex(unsigned index)
         return false;
     _dataElement.swap(dataElement);
     _alternativeIndex = index;
+    setDirty(true);
     return true;
 }