恢复Duplication(SceneNode *),并实现MeshComponent::Duplication...下一步Component::Duplication()改成由基类实现.
This commit is contained in:
@@ -94,6 +94,8 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
virtual Component *Duplication()=0;
|
||||
|
||||
//virtual void Update(const double delta_time)=0;
|
||||
|
||||
public: //事件
|
||||
@@ -105,6 +107,11 @@ public: //事件
|
||||
virtual void OnFocusGained(){} ///<焦点获得事件
|
||||
};//class Component
|
||||
|
||||
#define COMPONENT_CLASS_BODY(name) static name##ComponentManager *GetDefaultManager () {return name##ComponentManager::GetDefaultManager();} \
|
||||
name##ComponentManager *GetManager ()const {return (name##ComponentManager *)Component::GetManager();} \
|
||||
static constexpr const size_t StaticHashCode () {return hgl::GetTypeHash<name##Component>();} \
|
||||
const size_t GetHashCode ()const override{return name##Component::StaticHashCode();}
|
||||
|
||||
using ComponentSet=SortedSet<Component *>;
|
||||
using ComponentList=ArrayList<Component *>;
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user