1515#include " CMaterialLine3DBatcher.h"
1616#include " CPrimitiveBatcher.h"
1717#include " CPrimitiveMaterialBatcher.h"
18+ #include " CPrimitive3DBatcher.h"
19+ #include " CMaterialPrimitive3DBatcher.h"
1820#include " CAspectRatioConverter.h"
1921extern CCore* g_pCore;
2022extern bool g_bInGTAScene;
@@ -58,6 +60,10 @@ CGraphics::CGraphics(CLocalGUI* pGUI)
5860 m_pLine3DBatcherPostGUI = new CLine3DBatcher (false );
5961 m_pMaterialLine3DBatcherPreGUI = new CMaterialLine3DBatcher (true );
6062 m_pMaterialLine3DBatcherPostGUI = new CMaterialLine3DBatcher (false );
63+ m_pPrimitive3DBatcherPreGUI = new CPrimitive3DBatcher (true );
64+ m_pPrimitive3DBatcherPostGUI = new CPrimitive3DBatcher (false );
65+ m_pMaterialPrimitive3DBatcherPreGUI = new CMaterialPrimitive3DBatcher (true , this );
66+ m_pMaterialPrimitive3DBatcherPostGUI = new CMaterialPrimitive3DBatcher (false , this );
6167 m_pPrimitiveBatcher = new CPrimitiveBatcher ();
6268 m_pPrimitiveMaterialBatcher = new CPrimitiveMaterialBatcher (this );
6369
@@ -84,6 +90,10 @@ CGraphics::~CGraphics()
8490 SAFE_DELETE (m_pMaterialLine3DBatcherPostGUI);
8591 SAFE_DELETE (m_pPrimitiveBatcher);
8692 SAFE_DELETE (m_pPrimitiveMaterialBatcher);
93+ SAFE_DELETE (m_pPrimitive3DBatcherPreGUI);
94+ SAFE_DELETE (m_pPrimitive3DBatcherPostGUI);
95+ SAFE_DELETE (m_pMaterialPrimitive3DBatcherPreGUI);
96+ SAFE_DELETE (m_pMaterialPrimitive3DBatcherPostGUI);
8797 SAFE_DELETE (m_pScreenGrabber);
8898 SAFE_DELETE (m_pPixelsManager);
8999 SAFE_DELETE (m_pAspectRatioConverter);
@@ -898,6 +908,44 @@ void CGraphics::DrawPrimitiveQueued(std::vector<PrimitiveVertice>* pVecVertices,
898908 AddQueueItem (Item, bPostGUI);
899909}
900910
911+ void CGraphics::DrawPrimitive3DQueued (std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, bool bPostGUI)
912+ {
913+ // Prevent queuing when minimized
914+ if (g_pCore->IsWindowMinimized ())
915+ {
916+ delete pVecVertices;
917+ return ;
918+ }
919+
920+ // Add it to the queue
921+ if (bPostGUI && !CCore::GetSingleton ().IsMenuVisible ())
922+ m_pPrimitive3DBatcherPostGUI->AddPrimitive (eType, pVecVertices);
923+ else
924+ m_pPrimitive3DBatcherPreGUI->AddPrimitive (eType, pVecVertices);
925+ }
926+
927+ void CGraphics::DrawMaterialPrimitive3DQueued (std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial, bool bPostGUI)
928+ {
929+ // Prevent queuing when minimized
930+ if (g_pCore->IsWindowMinimized ())
931+ {
932+ delete pVecVertices;
933+ return ;
934+ }
935+
936+ if (CShaderItem* pShaderItem = DynamicCast<CShaderItem>(pMaterial))
937+ {
938+ // If material is a shader, use its current instance
939+ pMaterial = pShaderItem->m_pShaderInstance ;
940+ }
941+
942+ // Add it to the queue
943+ if (bPostGUI && !CCore::GetSingleton ().IsMenuVisible ())
944+ m_pMaterialPrimitive3DBatcherPostGUI->AddPrimitive (eType, pMaterial, pVecVertices);
945+ else
946+ m_pMaterialPrimitive3DBatcherPreGUI->AddPrimitive (eType, pMaterial, pVecVertices);
947+ }
948+
901949void CGraphics::DrawMaterialPrimitiveQueued (std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial,
902950 bool bPostGUI)
903951{
@@ -1437,7 +1485,10 @@ void CGraphics::OnDeviceCreate(IDirect3DDevice9* pDevice)
14371485 m_pMaterialLine3DBatcherPreGUI->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
14381486 m_pMaterialLine3DBatcherPostGUI->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
14391487 m_pPrimitiveBatcher->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
1440- m_pPrimitiveMaterialBatcher->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
1488+ m_pPrimitive3DBatcherPreGUI->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
1489+ m_pPrimitive3DBatcherPostGUI->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
1490+ m_pMaterialPrimitive3DBatcherPreGUI->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
1491+ m_pMaterialPrimitive3DBatcherPostGUI->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
14411492 m_pRenderItemManager->OnDeviceCreate (pDevice, GetViewportWidth (), GetViewportHeight ());
14421493 m_pScreenGrabber->OnDeviceCreate (pDevice);
14431494 m_pPixelsManager->OnDeviceCreate (pDevice);
@@ -1513,6 +1564,8 @@ void CGraphics::DrawPostGUIQueue()
15131564 DrawQueue (m_PostGUIQueue);
15141565 m_pLine3DBatcherPostGUI->Flush ();
15151566 m_pMaterialLine3DBatcherPostGUI->Flush ();
1567+ m_pPrimitive3DBatcherPostGUI->Flush ();
1568+ m_pMaterialPrimitive3DBatcherPostGUI->Flush ();
15161569
15171570 // Both queues should be empty now, and there should be no outstanding refs
15181571 assert (m_PreGUIQueue.empty () && m_iDebugQueueRefs == 0 );
@@ -1524,11 +1577,22 @@ void CGraphics::DrawLine3DPreGUIQueue()
15241577 m_pMaterialLine3DBatcherPreGUI->Flush ();
15251578}
15261579
1527- bool CGraphics::HasLine3DPreGUIQueueItems ()
1580+ void CGraphics::DrawPrimitive3DPreGUIQueue (void )
1581+ {
1582+ m_pPrimitive3DBatcherPreGUI->Flush ();
1583+ m_pMaterialPrimitive3DBatcherPreGUI->Flush ();
1584+ }
1585+
1586+ bool CGraphics::HasLine3DPreGUIQueueItems (void )
15281587{
15291588 return m_pLine3DBatcherPreGUI->HasItems () || m_pMaterialLine3DBatcherPreGUI->HasItems ();
15301589}
15311590
1591+ bool CGraphics::HasPrimitive3DPreGUIQueueItems (void )
1592+ {
1593+ return m_pMaterialPrimitive3DBatcherPreGUI->HasItems () || m_pPrimitive3DBatcherPreGUI->HasItems ();
1594+ }
1595+
15321596void CGraphics::DrawQueue (std::vector<sDrawQueueItem >& Queue)
15331597{
15341598 BeginDrawBatch ();
0 commit comments