SceneNode增加Component相关函数(但Component的释放还没有完全确定)
This commit is contained in:
parent
0b172bfc81
commit
ab3f771455
@ -69,10 +69,11 @@ namespace hgl
|
|||||||
LocalBoundingBox.SetZero();
|
LocalBoundingBox.SetZero();
|
||||||
|
|
||||||
ChildNode.Clear();
|
ChildNode.Clear();
|
||||||
|
ComponentList.Clear();
|
||||||
render_obj=nullptr;
|
render_obj=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool IsEmpty()const
|
const bool ChildNodeIsEmpty()const
|
||||||
{
|
{
|
||||||
if(render_obj)return(false);
|
if(render_obj)return(false);
|
||||||
if(ChildNode.GetCount())return(false);
|
if(ChildNode.GetCount())return(false);
|
||||||
@ -111,6 +112,14 @@ namespace hgl
|
|||||||
|
|
||||||
public: //组件相关方法
|
public: //组件相关方法
|
||||||
|
|
||||||
|
bool ComponentIsEmpty ()const {return ComponentList.GetCount()==0;} ///<是否没有组件
|
||||||
|
virtual int GetComponentCount ()const {return ComponentList.GetCount();} ///<取得组件数量
|
||||||
|
virtual void AddComponent (Component *comp) {ComponentList.Add(comp);} ///<添加一个组件
|
||||||
|
virtual void RemoveComponent (Component *comp) {ComponentList.DeleteByValue(comp);} ///<删除一个组件
|
||||||
|
bool Contains (Component *comp) {return ComponentList.Contains(comp);} ///<是否包含指定组件
|
||||||
|
|
||||||
|
bool HasComponent (const ComponentManager *); ///<是否有指定组件管理器的组件
|
||||||
|
virtual int GetComponents (List<Component *> &comp_list,const ComponentManager *); ///<取得所有组件
|
||||||
|
|
||||||
};//class SceneNode
|
};//class SceneNode
|
||||||
|
|
||||||
|
@ -88,5 +88,38 @@ namespace hgl
|
|||||||
|
|
||||||
LocalBoundingBox=local;
|
LocalBoundingBox=local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SceneNode::GetComponents(List<Component *> &comp_list,const ComponentManager *mgr)
|
||||||
|
{
|
||||||
|
if(!mgr)return(-1);
|
||||||
|
if(ComponentIsEmpty())return(0);
|
||||||
|
|
||||||
|
int result=0;
|
||||||
|
|
||||||
|
for(Component *c:ComponentList)
|
||||||
|
{
|
||||||
|
if(c->GetManager()==mgr)
|
||||||
|
{
|
||||||
|
comp_list.Add(c);
|
||||||
|
++result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SceneNode::HasComponent(const ComponentManager *mgr)
|
||||||
|
{
|
||||||
|
if(!mgr)return(false);
|
||||||
|
if(ComponentIsEmpty())return(false);
|
||||||
|
|
||||||
|
for(Component *c:ComponentList)
|
||||||
|
{
|
||||||
|
if(c->GetManager()==mgr)
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user