summaryrefslogtreecommitdiffstats
path: root/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp')
-rw-r--r--src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp b/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
index 03c1a01..4dade3f 100644
--- a/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
+++ b/src/runtimerender/Qt3DSRenderCustomMaterialSystem.cpp
@@ -956,7 +956,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
if (IsMaterialRegistered(inName))
return false;
m_CoreContext.GetDynamicObjectSystemCore().Register(
- inName, inProperties, sizeof(SCustomMaterial), GraphObjectTypes::CustomMaterial);
+ inName, inProperties, GraphObjectTypes::CustomMaterial);
IDynamicObjectClass *theClass =
m_CoreContext.GetDynamicObjectSystemCore().GetDynamicObjectClass(inName);
if (theClass == NULL) {
@@ -1103,7 +1103,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
SCustomMaterial *CreateCustomMaterial(CRegisteredString inName,
NVAllocatorCallback &inSceneGraphAllocator) override
{
- SCustomMaterial *theMaterial = static_cast<SCustomMaterial *>(
+ SCustomMaterial *theMaterial = QT3DS_NEW(inSceneGraphAllocator, SCustomMaterial)(
m_CoreContext.GetDynamicObjectSystemCore().CreateInstance(inName,
inSceneGraphAllocator));
SMaterialClass *theClass = GetMaterialClass(inName);
@@ -1358,15 +1358,16 @@ struct SMaterialSystem : public ICustomMaterialSystem
NVRenderShaderProgram &inShader, const SApplyInstanceValue &inCommand)
{
// sanity check
+ SDynamicObject &dynObj = *inMaterial.m_dynamicObject;
if (inCommand.m_PropertyName.IsValid()) {
bool canGetData =
inCommand.m_ValueOffset + getSizeofShaderDataType(inCommand.m_ValueType)
- <= inMaterial.m_DataSectionByteSize;
+ <= dynObj.m_DataSectionByteSize;
if (canGetData == false) {
QT3DS_ASSERT(false);
return;
}
- QT3DSU8 *dataPtr = inMaterial.GetDataSectionBegin() + inCommand.m_ValueOffset;
+ QT3DSU8 *dataPtr = dynObj.GetDataSectionOffset(inCommand.m_ValueOffset);
const SPropertyDefinition *theDefinition =
inClass.m_Class->FindPropertyByName(inCommand.m_PropertyName);
if (theDefinition)
@@ -1382,7 +1383,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
// This is fine, the property wasn't found and we continue, no problem.
if (!theConstant)
continue;
- QT3DSU8 *dataPtr = inMaterial.GetDataSectionBegin() + theDefinition.m_Offset;
+ QT3DSU8 *dataPtr = dynObj.GetDataSectionOffset(theDefinition.m_Offset);
DoApplyInstanceValue(inMaterial, dataPtr, theDefinition.m_Name,
theDefinition.m_DataType, inShader, theDefinition);
}
@@ -1944,7 +1945,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
for (QT3DSU32 idx = 0, end = theDefs.size(); idx < end; ++idx) {
const SPropertyDefinition &theDefinition(theDefs[idx]);
if (theDefinition.m_DataType == NVRenderShaderDataTypes::NVRenderTexture2DPtr) {
- QT3DSU8 *dataPtr = inMaterial.GetDataSectionBegin() + theDefinition.m_Offset;
+ QT3DSU8 *dataPtr = inMaterial.m_dynamicObject->GetDataSectionOffset(theDefinition.m_Offset);
StaticAssert<sizeof(CRegisteredString)
== sizeof(NVRenderTexture2DPtr)>::valid_expression();
CRegisteredString *theStrPtr = reinterpret_cast<CRegisteredString *>(dataPtr);
@@ -2012,7 +2013,7 @@ struct SMaterialSystem : public ICustomMaterialSystem
if (def.m_DataType == NVRenderShaderDataTypes::NVRenderTexture2DPtr) {
SImage *pImage = nullptr;
CRegisteredString theStrPtr = *reinterpret_cast<CRegisteredString *>(
- inMaterial.GetDataSectionBegin() + def.m_Offset);
+ inMaterial.m_dynamicObject->GetDataSectionOffset(def.m_Offset));
if (theStrPtr.IsValid()) {
QT3DSU32 index = FindAllocatedImage(theStrPtr);
@@ -2095,13 +2096,11 @@ struct SMaterialSystem : public ICustomMaterialSystem
for (QT3DSU32 idx = 0, end = thePropDefs.size(); idx < end; ++idx) {
if (thePropDefs[idx].m_DataType == NVRenderShaderDataTypes::QT3DSF32
&& AreEqual(thePropDefs[idx].m_Name.c_str(), "displaceAmount")) {
- QT3DSF32 theValue = *reinterpret_cast<const QT3DSF32 *>(inMaterial.GetDataSectionBegin()
- + thePropDefs[idx].m_Offset);
+ QT3DSF32 theValue = *reinterpret_cast<const QT3DSF32 *>(inMaterial.m_dynamicObject->GetDataSectionOffset(thePropDefs[idx].m_Offset));
inMaterial.m_DisplaceAmount = theValue;
} else if (thePropDefs[idx].m_DataType == NVRenderShaderDataTypes::QT3DSVec3
&& AreEqual(thePropDefs[idx].m_Name.c_str(), "displace_tiling")) {
- QT3DSVec3 theValue = *reinterpret_cast<const QT3DSVec3 *>(inMaterial.GetDataSectionBegin()
- + thePropDefs[idx].m_Offset);
+ QT3DSVec3 theValue = *reinterpret_cast<const QT3DSVec3 *>(inMaterial.m_dynamicObject->GetDataSectionOffset(thePropDefs[idx].m_Offset));
if (theValue.x != inMaterial.m_DisplacementMap->m_Scale.x
|| theValue.y != inMaterial.m_DisplacementMap->m_Scale.y) {
inMaterial.m_DisplacementMap->m_Scale = QT3DSVec2(theValue.x, theValue.y);