Added code that only renders objects which are active

This commit is contained in:
Kah Wei 2022-11-14 00:59:21 +08:00
parent 557a198367
commit ab869348f1
1 changed files with 17 additions and 1 deletions

View File

@ -27,6 +27,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h"
#include "Graphics/Descriptors/SHVkDescriptorPool.h"
#include "Scene/SHSceneManager.h"
namespace SHADE
{
@ -222,10 +223,25 @@ namespace SHADE
// Transform
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(rendId);
if (transform)
{
if (SHSceneManager::CheckNodeAndComponentsActive<SHRenderable>(rendId))
{
transformData.emplace_back(transform->GetTRS());
}
else
{
// Should be deactivated
static const SHMatrix ZERO_MTX =
{
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f
};
transformData.emplace_back(ZERO_MTX);
}
}
else
{
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!");
transformData.emplace_back();