Implement KRNode::RenderInfo

Use KRNode::RenderInfo to reduce render related argument counts and pass KRSurface through render functions.
Refactor render functions to use KRNode::RenderInfo
This commit is contained in:
2022-04-06 01:00:13 -07:00
parent 52c8ec2776
commit 767ba5932b
35 changed files with 319 additions and 282 deletions

View File

@@ -50,6 +50,7 @@ class KRMaterialManager;
class KRTextureManager;
class KRContext;
class KRScene;
class KRSurface;
class KRNode;
class KRPointLight;
@@ -83,6 +84,27 @@ public:
LOD_VISIBILITY_VISIBLE
};
class RenderInfo {
public:
RenderInfo(VkCommandBuffer& cb)
: commandBuffer(cb)
{
}
RenderInfo(const RenderInfo&) = delete;
RenderInfo& operator=(const RenderInfo&) = delete;
VkCommandBuffer& commandBuffer;
KRCamera* camera;
KRSurface* surface;
std::vector<KRPointLight*> point_lights;
std::vector<KRDirectionalLight*> directional_lights;
std::vector<KRSpotLight*> spot_lights;
KRViewport viewport;
RenderPass renderPass;
};
static void InitNodeInfo(KrNodeInfo* nodeInfo);
KRNode(KRScene &scene, std::string name);
@@ -193,7 +215,7 @@ public:
KRScene &getScene();
virtual void render(VkCommandBuffer& commandBuffer, KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, RenderPass renderPass);
virtual void render(const RenderInfo& ri);
virtual void physicsUpdate(float deltaTime);
virtual bool hasPhysics();