Fixed Renderables not being removed from a batch if their modifiable material was retrieved

This commit is contained in:
Kah Wei 2023-02-03 23:33:23 +08:00
parent a6290d9c8f
commit 940c55d665
5 changed files with 20 additions and 184 deletions

1
.gitignore vendored
View File

@ -366,3 +366,4 @@ MigrationBackup/
JSON/Schemas/Catalog/ JSON/Schemas/Catalog/
Assets/Editor/Editor.SHConfig Assets/Editor/Editor.SHConfig
Assets/Editor/Layouts/UserLayout.ini

View File

@ -1,167 +0,0 @@
[Window][MainStatusBar]
Pos=0,981
Size=1920,20
Collapsed=0
[Window][SHEditorMenuBar]
Pos=0,48
Size=1920,933
Collapsed=0
[Window][Hierarchy Panel]
Pos=0,186
Size=300,795
Collapsed=0
DockId=0x00000004,0
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Inspector]
Pos=1434,48
Size=486,933
Collapsed=0
DockId=0x00000006,0
[Window][Profiler]
Pos=0,48
Size=300,136
Collapsed=0
DockId=0x00000003,0
[Window][Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌð‡Žoû]
Pos=60,60
Size=32,64
Collapsed=0
[Window][ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ]
Pos=60,60
Size=999,581
Collapsed=0
[Window][ð‡]
Pos=60,60
Size=32,64
Collapsed=0
[Window][ÌÌÌÌ]
Pos=60,60
Size=553,422
Collapsed=0
[Window][]
Pos=60,60
Size=770,394
Collapsed=0
[Window][ Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][ Viewport]
Pos=227,48
Size=1457,1012
Collapsed=0
DockId=0x0000000B,0
[Window][î<> Viewport]
Pos=302,48
Size=1130,697
Collapsed=0
DockId=0x0000000B,0
[Window][V]
Pos=310,722
Size=1501,338
Collapsed=0
DockId=0x00000008,0
[Window][p£€Ê]
Pos=310,750
Size=1501,310
Collapsed=0
DockId=0x0000000A,0
[Window][ Asset Browser]
Pos=302,747
Size=1130,234
Collapsed=0
DockId=0x0000000C,0
[Window][Material Inspector]
Pos=1434,48
Size=486,933
Collapsed=0
DockId=0x00000006,1
[Window][Save scene as...]
Pos=1197,693
Size=165,120
Collapsed=0
[Window][Create New Asset]
Pos=896,472
Size=464,144
Collapsed=0
[Window][Collider Tag Panel]
Pos=302,48
Size=1130,697
Collapsed=0
DockId=0x0000000B,1
[Window][Input Bindings Panel]
Pos=1434,48
Size=486,933
Collapsed=0
DockId=0x00000006,2
[Window][Save Scene As]
Pos=877,444
Size=165,120
Collapsed=0
[Table][0x9D40AE32,17]
Column 0 Weight=0.9945
Column 1 Weight=0.9945
Column 2 Weight=0.9945
Column 3 Weight=0.9945
Column 4 Weight=0.9945
Column 5 Weight=0.9945
Column 6 Weight=0.9945
Column 7 Weight=0.9945
Column 8 Weight=0.9945
Column 9 Weight=0.9945
Column 10 Weight=0.9945
Column 11 Weight=0.9945
Column 12 Weight=1.0132
Column 13 Weight=0.8444
Column 14 Weight=0.9945
Column 15 Weight=1.2009
Column 16 Weight=1.0132
[Docking][Data]
DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,77 Size=1920,933 Split=X
DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1432,1036 Split=X
DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,863 Selected=0xE096E5AE
DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1130,1036 Split=Y Selected=0xB41284E7
DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7
DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0xB41284E7
DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,234 Selected=0xB128252A
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6
DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532
DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=486,1036 Selected=0xE7039252

View File

@ -210,7 +210,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!"); SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
} }
} }
} }
@ -290,20 +290,20 @@ namespace SHADE
// Build CPU Buffer // Build CPU Buffer
char* propsCurrPtr = matPropsData.get(); char* propsCurrPtr = matPropsData.get();
for (auto& subBatch : subBatches) for (auto& subBatch : subBatches)
for (auto rendId : subBatch.Renderables) for (auto rendId : subBatch.Renderables)
{
const SHRenderable* renderable = SHComponentManager::GetComponent_s<SHRenderable>(rendId);
if (renderable)
{ {
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId); renderable->GetMaterial()->ExportProperties(propsCurrPtr);
if (renderable)
{
renderable->GetMaterial()->ExportProperties(propsCurrPtr);
}
else
{
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!");
}
//propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize;
} }
else
{
SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
}
//propsCurrPtr += singleMatPropAlignedSize;
propsCurrPtr += singleMatPropSize;
}
// Transfer to GPU // Transfer to GPU
rebuildDescriptorSetBuffers(frameIndex, descPool); rebuildDescriptorSetBuffers(frameIndex, descPool);
@ -357,7 +357,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!"); SHLOG_WARNING("[SHBatch] Entity #{} containing a SHRenderable with no SHTransformComponent found!", rendId);
transformData.emplace_back(); transformData.emplace_back();
} }
} }
@ -578,7 +578,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!"); SHLOG_WARNING("[SHBatch] Entity #{} contianing a SHRenderable with no SHTransformComponent found!", rendId);
transformData.emplace_back(); transformData.emplace_back();
} }
@ -603,7 +603,7 @@ namespace SHADE
} }
else else
{ {
SHLOG_WARNING("[SHBatch] Entity with a missing SHRenderable found!"); SHLOG_WARNING("[SHBatch] Entity #{} with a missing SHRenderable found!", rendId);
} }
propsCurrPtr += singleMatPropSize; propsCurrPtr += singleMatPropSize;
} }

View File

@ -1055,7 +1055,7 @@ namespace SHADE
for (auto& renderable : renderables) for (auto& renderable : renderables)
{ {
// Check if the material instance is now unused // Check if the material instance is now unused
renderable.CleanUpMaterials(); renderable.CleanUpMaterials();
if (!renderable.HasChanged()) if (!renderable.HasChanged())
continue; continue;

View File

@ -99,6 +99,8 @@ namespace SHADE
{ {
SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>(); SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial); material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial);
oldMaterial = sharedMaterial;
oldMatIsShared = true;
matChanged = true; matChanged = true;
} }