diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-05-08 14:38:00 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2019-05-08 11:58:37 +0000 |
commit | f699744899fa6d149b21ab4412a2588854ae8dbc (patch) | |
tree | 6710db314a6126ce4bc2bfee76f35021472322c6 /src/Runtime | |
parent | 4d81269affaa5369caa4aa0fda2b0523fa3f8ea8 (diff) |
Add missing float4 types to Runtime data model datatypes
Task-number: QT3DS-3400
Change-Id: I17de1c3a1d6ba4a6877a9570ab9821523e345565
Reviewed-by: Jari Karppinen <jari.karppinen@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Runtime')
6 files changed, 64 insertions, 20 deletions
diff --git a/src/Runtime/Source/datamodel/Qt3DSMetadata.cpp b/src/Runtime/Source/datamodel/Qt3DSMetadata.cpp index 03c515e0..197582b0 100644 --- a/src/Runtime/Source/datamodel/Qt3DSMetadata.cpp +++ b/src/Runtime/Source/datamodel/Qt3DSMetadata.cpp @@ -292,6 +292,8 @@ public: return ERuntimeDataModelDataTypeFloat2; case DataModelDataType::Float3: return ERuntimeDataModelDataTypeFloat3; + case DataModelDataType::Float4: + return ERuntimeDataModelDataTypeFloat4; case DataModelDataType::Long: return ERuntimeDataModelDataTypeLong; case DataModelDataType::String: @@ -452,13 +454,13 @@ public: return Empty(); } - Option<qt3ds::QT3DSVec3> GetPropertyValueVector2(TStrTableStr inType, TStrTableStr inProperty, + Option<qt3ds::QT3DSVec2> GetPropertyValueVector2(TStrTableStr inType, TStrTableStr inProperty, TStrTableStr inId) override { SRuntimeMetaDataPropertyInfo &theInfo(FindProperty(inType, inProperty, inId)); if (theInfo.m_Value.hasValue()) { SFloat2 theFloat2 = qt3dsdm::get<SFloat2>(*theInfo.m_Value); - return qt3ds::QT3DSVec3(theFloat2[0], theFloat2[1], 0); + return qt3ds::QT3DSVec2(theFloat2[0], theFloat2[1]); } return Empty(); } diff --git a/src/Runtime/Source/datamodel/Qt3DSMetadata.h b/src/Runtime/Source/datamodel/Qt3DSMetadata.h index ea2d4452..1efe748c 100644 --- a/src/Runtime/Source/datamodel/Qt3DSMetadata.h +++ b/src/Runtime/Source/datamodel/Qt3DSMetadata.h @@ -32,6 +32,7 @@ #include "foundation/Qt3DSRefCounted.h" #include "foundation/Qt3DSOption.h" +#include "foundation/Qt3DSVec2.h" #include "foundation/Qt3DSVec3.h" #include "foundation/Qt3DSVec4.h" #include <EASTL/string.h> @@ -71,6 +72,7 @@ enum ERuntimeDataModelDataType { ERuntimeDataModelDataTypeFloat, ERuntimeDataModelDataTypeFloat2, ERuntimeDataModelDataTypeFloat3, + ERuntimeDataModelDataTypeFloat4, ERuntimeDataModelDataTypeLong, ERuntimeDataModelDataTypeString, ERuntimeDataModelDataTypeBool, @@ -205,14 +207,14 @@ public: //============================================================================== /** - * Get property value as QT3DSVec3 + * Get property value as QT3DSVec2 * @param inType default object type * @param inProperty the property to query * @param inId object id. if this value is not trivial, the query is based on inId *instead of inType * @param return property value */ - virtual Option<qt3ds::QT3DSVec3> GetPropertyValueVector2(TStrTableStr inType, TStrTableStr inProperty, + virtual Option<qt3ds::QT3DSVec2> GetPropertyValueVector2(TStrTableStr inType, TStrTableStr inProperty, TStrTableStr inId = TStrTableStr()) = 0; //============================================================================== diff --git a/src/Runtime/Source/runtime/Qt3DSElementSystem.cpp b/src/Runtime/Source/runtime/Qt3DSElementSystem.cpp index 44850859..d8e18338 100644 --- a/src/Runtime/Source/runtime/Qt3DSElementSystem.cpp +++ b/src/Runtime/Source/runtime/Qt3DSElementSystem.cpp @@ -379,7 +379,7 @@ struct SElementAllocator : public qt3ds::runtime::IElementAllocator theTypeDesc->m_DynamicProperties.push_back(*newProp); } else if (thePropertyType == Q3DStudio::ERuntimeDataModelDataTypeFloat2) { - qt3ds::QT3DSVec3 value = theMetaData.GetPropertyValueVector2( + qt3ds::QT3DSVec2 value = theMetaData.GetPropertyValueVector2( element.m_TypeDescription->m_TypeName, theWorkSpaceString, element.m_TypeDescription->m_SubtypeName); newProp->m_Type = Q3DStudio::ATTRIBUTETYPE_FLOAT; diff --git a/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp b/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp index 3fb7b53f..1037486b 100644 --- a/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp +++ b/src/Runtime/Source/runtimerender/Qt3DSRenderUIPLoader.cpp @@ -222,11 +222,11 @@ struct SMetaPropertyParser : public IPropertyParser } Option<QT3DSVec2> ParseVec2(const char8_t *inName) override { - Option<qt3ds::QT3DSVec3> theProperty = + Option<qt3ds::QT3DSVec2> theProperty = m_MetaData.GetPropertyValueVector2(m_Type, Register(inName), m_ClassId); - if (theProperty.hasValue()) { - return QT3DSVec2(theProperty->x, theProperty->y); - } + if (theProperty.hasValue()) + return *theProperty; + return Empty(); } Option<QT3DSVec3> ParseVec3(const char8_t *inName) override diff --git a/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.cpp b/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.cpp index 2ddffe3f..e758f0af 100644 --- a/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.cpp +++ b/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.cpp @@ -187,6 +187,9 @@ SElementPropertyInfo *SParseElementManager::GetOrCreateProperty(SElementData &in case ERuntimeDataModelDataTypeFloat3: retval.m_Arity = 3; break; + case ERuntimeDataModelDataTypeFloat4: + retval.m_Arity = 4; + break; } if (retval.m_Arity > 1) { if (retval.m_Arity == 2) { @@ -194,7 +197,7 @@ SElementPropertyInfo *SParseElementManager::GetOrCreateProperty(SElementData &in thePropNames, m_StringTable); SetPropertyValueHash(m_Workspace, ".y", thePropHashes, thePeriodPos, thePropNames, m_StringTable); - } else { + } else if (retval.m_Arity == 3) { if (m_MetaData.GetAdditionalType(theData.m_Type, theStr, theData.m_Class) == ERuntimeAdditionalMetaDataTypeColor) { SetPropertyValueHash(m_Workspace, ".r", thePropHashes, thePeriodPos, @@ -211,6 +214,18 @@ SElementPropertyInfo *SParseElementManager::GetOrCreateProperty(SElementData &in SetPropertyValueHash(m_Workspace, ".z", thePropHashes, thePeriodPos, thePropNames, m_StringTable); } + } else if (retval.m_Arity == 4) { + if (m_MetaData.GetAdditionalType(theData.m_Type, theStr, theData.m_Class) + == ERuntimeAdditionalMetaDataTypeColor) { + SetPropertyValueHash(m_Workspace, ".r", thePropHashes, thePeriodPos, + thePropNames, m_StringTable); + SetPropertyValueHash(m_Workspace, ".g", thePropHashes, thePeriodPos, + thePropNames, m_StringTable); + SetPropertyValueHash(m_Workspace, ".b", thePropHashes, thePeriodPos, + thePropNames, m_StringTable); + SetPropertyValueHash(m_Workspace, ".a", thePropHashes, thePeriodPos, + thePropNames, m_StringTable); + } } } else { retval.m_PropertyHashes[0] = Q3DStudio::CHash::HashAttribute(theStr.c_str()); @@ -675,10 +690,6 @@ BOOL CUIPParserImpl::LoadGraph(IPresentation &inPresentation, qt3dsdm::IDOMReade return theLoadResult; } -inline RuntimeVector3 Convert(const QT3DSVec3 &input) -{ - return RuntimeVector3(input.x, input.y, input.z); -} using qt3ds::runtime::element::SPropertyDesc; using qt3ds::runtime::element::TPropertyDescAndValue; @@ -697,21 +708,27 @@ void CUIPParserImpl::GetMetaAttribute(IPresentation &inPresentation, m_MetaData.GetPropertyValueFloat(inType, inName, inClassId)); break; case ERuntimeDataModelDataTypeFloat2: { - RuntimeVector3 theVector3 = - Convert(m_MetaData.GetPropertyValueVector2(inType, inName, inClassId)); - SFloat2 theValue(theVector3.m_X, theVector3.m_Y); + QT3DSVec2 vec2 = m_MetaData.GetPropertyValueVector2(inType, inName, inClassId); + SFloat2 theValue(vec2.x, vec2.y); AddFloat2Attribute(outDescList, inAttStrNames, theValue); break; } case ERuntimeDataModelDataTypeFloat3: { - RuntimeVector3 theVector3 = - Convert(m_MetaData.GetPropertyValueVector3(inType, inName, inClassId)); - SFloat3 theValue(theVector3.m_X, theVector3.m_Y, theVector3.m_Z); + QT3DSVec3 vec3 = m_MetaData.GetPropertyValueVector3(inType, inName, inClassId); + SFloat3 theValue(vec3.x, vec3.y, vec3.z); ERuntimeAdditionalMetaDataType theAdditionalType = m_MetaData.GetAdditionalType(inType, inName, inClassId); AddFloat3Attribute(outDescList, theAdditionalType, inAttStrNames, theValue); break; } + case ERuntimeDataModelDataTypeFloat4: { + QT3DSVec4 vec4 = m_MetaData.GetPropertyValueVector4(inType, inName, inClassId); + SFloat4 theValue(vec4.x, vec4.y, vec4.z, vec4.w); + ERuntimeAdditionalMetaDataType theAdditionalType = + m_MetaData.GetAdditionalType(inType, inName, inClassId); + AddFloat4Attribute(outDescList, theAdditionalType, inAttStrNames, theValue); + break; + } case ERuntimeDataModelDataTypeLong: AddLongAttribute(outDescList, inAttStrNames[0], m_MetaData.GetPropertyValueLong(inType, inName, inClassId)); @@ -798,6 +815,19 @@ void CUIPParserImpl::AddFloat3Attribute(TPropertyDescAndValueList &outDescList, } } +void CUIPParserImpl::AddFloat4Attribute(TPropertyDescAndValueList &outDescList, + ERuntimeAdditionalMetaDataType inAdditionalType, + CRegisteredString *inAttStrNames, SFloat4 &inValue) +{ + for (long i = 0; i < 4; ++i) { + UVariant varVal; + varVal.m_FLOAT = inValue[i]; + outDescList.push_back(eastl::make_pair( + SPropertyDesc(inAttStrNames[i], ATTRIBUTETYPE_FLOAT), varVal)); + } +} + + void CUIPParserImpl::AddStringAttribute(IPresentation &inPresentation, TPropertyDescAndValueList &outDescList, CRegisteredString inAttStrName, const char *inValue) @@ -883,6 +913,13 @@ void CUIPParserImpl::GetAttributeList(IPresentation &inPresentation, AddFloat3Attribute(outDescList, inAdditionalType, inPropNameStrs, theValue); break; } + case ERuntimeDataModelDataTypeFloat4: { + SFloat4 theValue(0); + if (!IsTrivial(inValue)) + theReader.ReadRef(NVDataRef<QT3DSF32>(&theValue[0], 4)); + AddFloat4Attribute(outDescList, inAdditionalType, inPropNameStrs, theValue); + break; + } case ERuntimeDataModelDataTypeBool: { bool theValue = false; if (!IsTrivial(inValue)) diff --git a/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.h b/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.h index fd921161..585dd857 100644 --- a/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.h +++ b/src/Runtime/Source/uipparser/Qt3DSUIPParserImpl.h @@ -644,6 +644,9 @@ protected: void AddFloat3Attribute(TPropertyDescAndValueList &outDescList, ERuntimeAdditionalMetaDataType inAdditionalType, CRegisteredString *inAttStrNames, qt3dsdm::SFloat3 &inValue); + void AddFloat4Attribute(TPropertyDescAndValueList &outDescList, + ERuntimeAdditionalMetaDataType inAdditionalType, + CRegisteredString *inAttStrNames, qt3dsdm::SFloat4 &inValue); void AddStringAttribute(IPresentation &inPresentation, TPropertyDescAndValueList &outDescList, CRegisteredString inAttStrName, const char *inValue); void AddElementRefAttribute(TPropertyDescAndValueList &outDescList, |