WorkObject inherit TickObject.

This commit is contained in:
hyzboy 2025-01-25 20:07:52 +08:00
parent a569d08269
commit 7326765057

View File

@ -2,17 +2,17 @@
#include<hgl/graph/RenderFramework.h> #include<hgl/graph/RenderFramework.h>
#include<hgl/graph/module/SwapchainModule.h> #include<hgl/graph/module/SwapchainModule.h>
#include<hgl/graph/VKRenderResource.h> #include<hgl/graph/VKRenderResource.h>
#include<hgl/type/object/TickObject.h>
#include<hgl/Time.h> #include<hgl/Time.h>
namespace hgl namespace hgl
{ {
class WorkObject class WorkObject:public TickObject
{ {
graph::RenderFramework *render_framework=nullptr; graph::RenderFramework *render_framework=nullptr;
bool destroy_flag=false; bool destroy_flag=false;
bool tickable=true;
bool renderable=true; bool renderable=true;
protected: protected:
@ -28,11 +28,9 @@ namespace hgl
public: public:
const bool IsDestroy()const{return destroy_flag;} const bool IsDestroy()const{return destroy_flag;}
const bool IsTickable()const{return tickable;}
const bool IsRenderable()const{return renderable;} const bool IsRenderable()const{return renderable;}
void MarkDestory(){destroy_flag=true;} void MarkDestory(){destroy_flag=true;}
void SetTickable(bool t){tickable=t;}
void SetRenderable(bool r){renderable=r;} void SetRenderable(bool r){renderable=r;}
public: public:
@ -52,7 +50,6 @@ namespace hgl
db=rf->GetRenderResource(); db=rf->GetRenderResource();
} }
virtual void Tick(double delta_time)=0;
virtual void Render(double delta_time)=0; virtual void Render(double delta_time)=0;
};//class WorkObject };//class WorkObject
@ -87,7 +84,7 @@ namespace hgl
frame_time=1.0f/double(fps); frame_time=1.0f/double(fps);
} }
void Update(WorkObject *wo) void Tick(WorkObject *wo)
{ {
double delta_time=cur_time-last_update_time; double delta_time=cur_time-last_update_time;
@ -122,7 +119,7 @@ namespace hgl
cur_time=GetDoubleTime(); cur_time=GetDoubleTime();
if(cur_work_object->IsTickable()) if(cur_work_object->IsTickable())
Update(cur_work_object); Tick(cur_work_object);
if(win->IsVisible()&&cur_work_object->IsRenderable()) if(win->IsVisible()&&cur_work_object->IsRenderable())
{ {