]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLAArrayDataType.cxx
math: Move lerp function into SGMisc.
[simgear.git] / simgear / hla / HLAArrayDataType.cxx
index f52da2830828f8fd8a8b05517df7a6f24d11b2bb..8f6435b602f821f7eecc6e9c56fbbcbaff16eb24 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 - 2011  Mathias Froehlich - Mathias.Froehlich@web.de
+// Copyright (C) 2009 - 2012  Mathias Froehlich - Mathias.Froehlich@web.de
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Library General Public
@@ -44,12 +44,16 @@ HLAArrayDataType::toArrayDataType() const
     return this;
 }
 
+void
+HLAArrayDataType::releaseDataTypeReferences()
+{
+    _elementDataType = 0;
+    HLADataType::releaseDataTypeReferences();
+}
+
 void
 HLAArrayDataType::setElementDataType(const HLADataType* elementDataType)
 {
-    // FIXME this only works if we do not reset the alignment to something smaller
-    if (getAlignment() < elementDataType->getAlignment())
-        setAlignment(elementDataType->getAlignment());
     _elementDataType = elementDataType;
 }
 
@@ -65,6 +69,15 @@ HLAArrayDataType::setIsString(bool isString)
     _isString = isString;
 }
 
+void
+HLAArrayDataType::_recomputeAlignmentImplementation()
+{
+    unsigned alignment = 1;
+    if (const HLADataType* dataType = getElementDataType())
+        alignment = std::max(alignment, dataType->getAlignment());
+    setAlignment(alignment);
+}
+
 ///////////////////////////////////////////////////////////////////////////////////
 
 HLAFixedArrayDataType::HLAFixedArrayDataType(const std::string& name) :
@@ -160,13 +173,20 @@ HLAVariableArrayDataType::encode(HLAEncodeStream& stream, const HLAAbstractArray
 }
 
 void
-HLAVariableArrayDataType::setSizeDataType(const HLADataType* sizeDataType)
+HLAVariableArrayDataType::setSizeDataType(const HLABasicDataType* sizeDataType)
 {
-    // FIXME this only works if we do not reset the alignment to something smaller
-    if (getAlignment() < sizeDataType->getAlignment())
-        setAlignment(sizeDataType->getAlignment());
     _sizeDataType = sizeDataType;
-    // setAlignment(SGMisc<unsigned>::max(_sizeDataType->getAlignment(), _elementDataType->getAlignment());
+}
+
+void
+HLAVariableArrayDataType::_recomputeAlignmentImplementation()
+{
+    unsigned alignment = 1;
+    if (const HLADataType* dataType = getElementDataType())
+        alignment = std::max(alignment, dataType->getAlignment());
+    if (const HLADataType* dataType = getSizeDataType())
+        alignment = std::max(alignment, dataType->getAlignment());
+    setAlignment(alignment);
 }
 
 } // namespace simgear