Merge pull request #225 from SHADE-DP/SP3-1-RenderOnlyActive

Renderables now no longer render if disabled
This commit is contained in:
XiaoQiDigipen 2022-11-19 16:24:22 +08:00 committed by GitHub
commit 8753bc14a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 6 deletions

View File

@ -27,6 +27,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Math/Transform/SHTransformComponent.h" #include "Math/Transform/SHTransformComponent.h"
#include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h" #include "Graphics/MiddleEnd/GlobalData/SHGraphicsGlobalData.h"
#include "Graphics/Descriptors/SHVkDescriptorPool.h" #include "Graphics/Descriptors/SHVkDescriptorPool.h"
#include "Scene/SHSceneManager.h"
namespace SHADE namespace SHADE
{ {
@ -302,7 +303,22 @@ namespace SHADE
auto transform = SHComponentManager::GetComponent<SHTransformComponent>(rendId); auto transform = SHComponentManager::GetComponent<SHTransformComponent>(rendId);
if (transform) if (transform)
{ {
transformData.emplace_back(transform->GetTRS()); 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 else
{ {
@ -425,14 +441,29 @@ namespace SHADE
{ {
// Transform // Transform
auto transform = SHComponentManager::GetComponent_s<SHTransformComponent>(rendId); auto transform = SHComponentManager::GetComponent_s<SHTransformComponent>(rendId);
if (!transform) if (transform)
{ {
SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!"); if (SHSceneManager::CheckNodeAndComponentsActive<SHRenderable>(rendId))
transformData.emplace_back(); {
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 else
{ {
transformData.emplace_back(transform->GetTRS()); SHLOG_WARNING("[SHBatch] Entity contianing a SHRenderable with no SHTransformComponent found!");
transformData.emplace_back();
} }
const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId); const SHRenderable* renderable = SHComponentManager::GetComponent<SHRenderable>(rendId);