恢复Duplication(SceneNode *),并实现MeshComponent::Duplication...下一步Component::Duplication()改成由基类实现.

This commit is contained in:
2025-06-16 00:02:07 +08:00
parent dd2ee57954
commit a23654c73a
4 changed files with 40 additions and 28 deletions

View File

@@ -61,31 +61,33 @@ class MeshComponent:public RenderComponent
{
MeshComponentData *sm_data;
public:
COMPONENT_CLASS_BODY(Mesh)
public:
MeshComponent(MeshComponentData *cd,MeshComponentManager *cm):RenderComponent(cd,cm){sm_data=cd;}
virtual ~MeshComponent()=default;
static MeshComponentManager *GetDefaultManager()
{
return MeshComponentManager::GetDefaultManager();
}
static constexpr const size_t StaticHashCode()
{
return hgl::GetTypeHash<MeshComponent>();
}
const size_t GetHashCode()const override
{
return MeshComponent::StaticHashCode();
}
MeshComponentData &GetData() {return *sm_data;}
const MeshComponentData &GetData()const {return *sm_data;}
Mesh *GetMesh() const{return sm_data->mesh;}
public:
virtual Component *Duplication() override
{
MeshComponentManager *manager=GetManager();
MeshComponent *mc=manager->CreateComponent(sm_data->mesh);
mc->SetLocalMatrix(GetLocalMatrix());
return mc;
}
};//class MeshComponent
COMPONENT_NAMESPACE_END