Fixed bug where different Renderables of different meshes are thrown into the same SubBatch
This commit is contained in:
parent
187329c384
commit
e9496bead6
|
@ -42,7 +42,7 @@ namespace Sandbox
|
|||
std::vector<Handle<SHMesh>> handles;
|
||||
for (auto const& mesh : meshes)
|
||||
{
|
||||
handles.push_back(graphicsSystem->AddMesh(
|
||||
handles.push_back(graphicsSystem->AddMesh(
|
||||
mesh.header.vertexCount,
|
||||
mesh.vertexPosition.data(),
|
||||
mesh.texCoords.data(),
|
||||
|
@ -90,19 +90,22 @@ namespace Sandbox
|
|||
// stressTestObjects.emplace_back(entity);
|
||||
//}
|
||||
|
||||
auto entity = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
|
||||
auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(entity);
|
||||
auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(entity);
|
||||
auto entity = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
|
||||
auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(entity);
|
||||
auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(entity);
|
||||
|
||||
renderable.Mesh = handles.front();
|
||||
renderable.SetMaterial(matInst);
|
||||
renderable.Mesh = handles.front();
|
||||
renderable.SetMaterial(matInst);
|
||||
|
||||
//transform.SetLocalScale(TEST_OBJ_SCALE);
|
||||
////transform.SetLocalScale(TEST_OBJ_SCALE);
|
||||
|
||||
stressTestObjects.emplace_back(entity);
|
||||
//stressTestObjects.emplace_back(entity);
|
||||
|
||||
// Create blank entity with a script
|
||||
testObj = SHADE::SHEntityManager::CreateEntity();
|
||||
testObj = SHADE::SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
|
||||
auto& testObjRenderable = *SHComponentManager::GetComponent_s<SHRenderable>(testObj);
|
||||
testObjRenderable.Mesh = CUBE_MESH;
|
||||
testObjRenderable.SetMaterial(matInst);
|
||||
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
||||
scriptEngine->AddScript(testObj, "TestScript");
|
||||
}
|
||||
|
|
|
@ -540,9 +540,13 @@ namespace SHADE
|
|||
oldSuperBatch->Remove(&renderable);
|
||||
}
|
||||
|
||||
// Add to new SuperBatch
|
||||
Handle<SHSuperBatch> newSuperBatch = renderable.GetMaterial()->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||
newSuperBatch->Add(&renderable);
|
||||
// Add to new SuperBatch if there is a material
|
||||
Handle<SHMaterialInstance> newMatInstance = renderable.GetMaterial();
|
||||
if (newMatInstance)
|
||||
{
|
||||
Handle<SHSuperBatch> newSuperBatch = newMatInstance->GetBaseMaterial()->GetPipeline()->GetPipelineState().GetSubpass()->GetSuperBatch();
|
||||
newSuperBatch->Add(&renderable);
|
||||
}
|
||||
|
||||
// Unset change flag
|
||||
renderable.ResetChangedFlag();
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------------*/
|
||||
/* Usage Functions */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
inline Id GetId() const;
|
||||
inline Id GetId() const noexcept;
|
||||
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
/* Overloaded Operators */
|
||||
|
@ -62,7 +62,7 @@ namespace SHADE
|
|||
/// <summary>
|
||||
/// Converts to true if this is a valid Handle.
|
||||
/// </summary>
|
||||
inline operator bool() const;
|
||||
inline operator bool() const noexcept;
|
||||
|
||||
protected:
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
|
@ -101,6 +101,7 @@ namespace SHADE
|
|||
/*-----------------------------------------------------------------------------*/
|
||||
/* Overloaded Operators */
|
||||
/*-----------------------------------------------------------------------------*/
|
||||
inline bool operator==(const Handle<T>& rhs) const noexcept;
|
||||
/// <summary>
|
||||
/// Returns the underlying object pointed to by the Handle.
|
||||
/// </summary>
|
||||
|
|
|
@ -8,15 +8,15 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
/* HandleBase - Usage Functions */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
inline HandleBase::Id HandleBase::GetId() const
|
||||
inline HandleBase::Id HandleBase::GetId() const noexcept
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* HandleBase - Overloaded Operators */
|
||||
inline HandleBase::operator bool() const
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
inline HandleBase::operator bool() const noexcept
|
||||
{
|
||||
return id.Raw != INVALID_ID.Raw;
|
||||
}
|
||||
|
@ -33,6 +33,12 @@ namespace SHADE
|
|||
/*---------------------------------------------------------------------------------*/
|
||||
/* Handle<T> - Overloaded Operators */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
template<typename T>
|
||||
bool SHADE::Handle<T>::operator==(const Handle<T>& rhs) const noexcept
|
||||
{
|
||||
return id.Raw == rhs.id.Raw && library == rhs.library;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T& Handle<T>::operator*()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue